C# save a file from a HTTP Request
Posted
by d1k_is
on Stack Overflow
See other posts from Stack Overflow
or by d1k_is
Published on 2010-05-29T08:01:31Z
Indexed on
2010/05/29
8:02 UTC
Read the original article
Hit count: 190
c#
Im trying to download and save a file from a HttpWebResponse but im having problems saving the file (other than Text Files) properly.
I think its something to do with this part:
byte[] byteArray = Encoding.UTF8.GetBytes(http.Response.Content);
MemoryStream stream = new MemoryStream(byteArray);
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)
© Stack Overflow or respective owner