Groups | Blog | Home
all groups > dotnet sdk > february 2007 >

dotnet sdk : does anyone see what is wrong with my .gif download logic? no matter what image url i try it downloads a junk file that can't be opened in any paint p


dr
2/18/2007 10:23:22 PM
does anyone see what is wrong with my .gif download logic? no matter what
image url i try it downloads a junk file that can't be opened in any paint
program.


System.Net.WebRequest myRequest = System.Net.WebRequest.Create(url);
System.Net.WebResponse myResponse = myRequest.GetResponse();
System.IO.Stream imgStream = myResponse.GetResponseStream();
long len = myResponse.ContentLength;
byte[] binarydata = new byte[len];
System.IO.Stream streambinary = myResponse.GetResponseStream();
streambinary.Read(binarydata, 0, (int)len);
using(System.IO.BinaryWriter binWriter = new
System.IO.BinaryWriter(System.IO.File.Open(@"C:\foo.gif",
System.IO.FileMode.Create)))
{
binWriter.Write(binarydata, 0, (int)len);
}








Peter Ritchie [C# MVP]
4/3/2007 10:36:13 AM
Do ContentLength and streamBinary.Length have the same values?
--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


[quoted text, click to view]
AddThis Social Bookmark Button