title: C# save a file from a HTTP Response
body: <p>Im trying to download and save a file from a HttpWebResponse but im having problems saving the file (other than Text Files) properly.</p>
  
  <p>I think its something to do with this part: </p>
  
  <pre><code>byte[] byteArray = Encoding.UTF8.GetBytes(http.Response.Content);
  MemoryStream stream = new MemoryStream(byteArray);
  </code></pre>
  
  <p>Text Files work fine with the above code but when I try to save the Content to an Image file it gets corrupted.
  How do i write this 'string' data to an image file (and other binary files)</p>
  
  <p>Forgot to mention, This is .NET CP 3.5 and I have a wrapper class around the HttpWebResponse class to add OAuth etc.</p>