Thread: Download an image from a URL

  1. #1
    Registered User
    Join Date
    Apr 2002

    Download an image from a URL

    Hey everyone,

    I'm having problems downloading an image from in internet location.

    I've tried 2 methods:

    request = (HttpWebRequest)WebRequest.Create(newUrl);
    request.Method = "GET";
    response = (HttpWebResponse)request.GetResponse();
    Stream imageStream = response.GetResponseStream();
    Bitmap bmp = new Bitmap(imageStream);

    WebClient client = new WebClient();                                
    client.DownloadFile(newUrl, fileName);
    The first method throws an exception in the Bitmap constructor "Invalid parameter used." The second method saves the picture, put it is in the wrong format or something, because it can't be viewed, and is only 917 bytes on disk (actual image is 84000 bytes.)

    Any ideas or other methods that can be used to download images?


  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Hannover, Germany
    PHP Code:
    System.Net.WebClient client = new System.Net.WebClient();
    This saves the cprog image just fine. Make sure you have internet access and your connection or the server does not go down while downloading

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Apr 2002
    As it turns out, there was just something whack with the image I was trying to download. All other images worked fine. Thanks for the reply!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem reading tiff image files?
    By compz in forum C++ Programming
    Replies: 9
    Last Post: 10-30-2009, 04:17 AM
  2. image download program
    By yoda855 in forum Windows Programming
    Replies: 6
    Last Post: 06-30-2006, 11:37 AM
  3. Replies: 4
    Last Post: 03-02-2003, 09:12 AM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  5. download free bsd image?
    By iain in forum A Brief History of
    Replies: 5
    Last Post: 10-11-2002, 10:10 AM