title: Wrapper class to download image + Stream was not readable
body: <p>I have read many articles but im not sure if this can be resolved the way i have constructed this wrapper class to make WebRequests etc.</p>
  
  <p>Heres the code - this is some of the code from my wrapper class (only the relevant section is here)</p>
  
  <pre><code>        public Stream ResponseStream
          {
              get { return m_ResponseStream; }
          }
  
  public SendRequest(string Url)
  {
              HttpWebRequest WebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(URL);
              HttpWebResponse WebResponse = null;
              StreamReader ResponseReader = null;
  
              // Set default values here. Removed for clarity
              // Get Method etc
  
              try
              {
                  using (WebResponse = (System.Net.HttpWebResponse)WebRequest.GetResponse())
                  {
                      if (WebResponse != null)
                      {
                          m_StatusCode = WebResponse.StatusCode;
                          using (m_ResponseStream = WebResponse.GetResponseStream())
                          {
                              using (ResponseReader = new StreamReader(m_ResponseStream, ResponseEncoding))
                              {
                                  m_Response = ResponseReader.ReadToEnd();
                              }
  
                              m_ResponseStream.Flush();
                              m_ResponseStream.Close();
                          }
                      }
                  }
  
              }
              catch (WebException we)
              {
                  // Handle WebException
              }
              catch (Exception ex)
              {
                  // Handle Exception
              }
              finally
              {
  
              }
          }
  </code></pre>
  
  <p>I would like to download an image from a URL so i call the wrapper class function here as below in a web page after instantiating an instance of the above class:</p>
  
  <pre><code>public void DownloadImage()
  {
      WebServiceWrapper wr = new WebServiceWrapper();
      wr.SendRequest("http://example.com/someimage.jpg");
  
      using (BinaryReader reader = new BinaryReader(wr.ResponseStream))
      {
          Byte[] lnByte = reader.ReadBytes(1 * 1024 * 1024 * 10);
          using (FileStream lxFS = new FileStream("34891.jpg", FileMode.Create))
          {
              lxFS.Write(lnByte, 0, lnByte.Length);
          }
      }
  }
  </code></pre>
  
  <p>The line </p>
  
  <pre><code>using (BinaryReader reader = new BinaryReader(wr.ResponseStream))
  </code></pre>
  
  <p>returns back the error </p>
  
  <p><em>Exception Details: System.ArgumentException: Stream was not readable.</em></p>
  
  <p>So after further research it seems that ive not closed/flushed the StreamReader which i have but im not sure if ive missed off anything else or if its just not possible to do it this way?</p>