does anyone see what is wrong with my .gif download logic? no matter what image url i try it downloa

Discussion in 'ASP .Net' started by dr, Feb 19, 2007.

  1. dr

    dr Guest

    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);
    }
    dr, Feb 19, 2007
    #1
    1. Advertising

  2. Re: does anyone see what is wrong with my .gif download logic? nomatter what image url i try it downloads a junk file that can't be openedin any paint program.

    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
    =?ISO-8859-1?Q?G=F6ran_Andersson?=, Feb 19, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hb
    Replies:
    6
    Views:
    9,095
  2. Steve Juranich
    Replies:
    40
    Views:
    795
    Edvard Majakari
    Jul 13, 2005
  3. Steve
    Replies:
    0
    Views:
    510
    Steve
    Sep 25, 2006
  4. Beauregard T. Shagnasty

    Re: filename.gif or filename.gif.jpg?

    Beauregard T. Shagnasty, May 30, 2008, in forum: HTML
    Replies:
    1
    Views:
    727
    Jonathan N. Little
    May 30, 2008
  5. Bergamot
    Replies:
    0
    Views:
    428
    Bergamot
    May 30, 2008
Loading...

Share This Page