PC Review


Reply
Thread Tools Rate Thread

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.

 
 
dr
Guest
Posts: n/a
 
      19th Feb 2007
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);
}








 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      19th Feb 2007
dr wrote:
> 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);
> }
>


I replied to this in the C# group. If you post to several groups, please
to a proper cross posting, so that the replies appear in all groups.

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Free download - paint program Donny Windows Vista General Discussion 3 16th Apr 2007 03:08 AM
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. dr Microsoft C# .NET 6 20th Feb 2007 05:01 AM
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. dr Microsoft Dot NET 1 19th Feb 2007 12:42 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. dr Microsoft ASP .NET 1 19th Feb 2007 07:47 AM
Need to Download Paint program Kara Windows XP General 3 28th Nov 2003 08:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:25 PM.