how to download and store web images

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I am pulling xhtml content from a data provider that I manipulate and store
in a DB.

Before storing the xhtml fragment in the DB,I want to discover all <img>
tags, download the target image to the local filesystem, and change the img
src to point to the new location.

Do you know which classes can help me pull down an image given a URI?
Once I get the image, is it possible to discover the image type (GIF/JPG/PNG)?

I have not been able to find a lot of useful information on this topic and
would greatly appreciate your help.

Thanks,
-Keith
 
Do you know which classes can help me pull down an image given a URI?

Check out System.Net.HttpWebRequest and HttpWebResponse.
Once I get the image, is it possible to discover the image type
(GIF/JPG/PNG)?

You should be able to inspect the content type on the response.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
In VB2005 you can download and store images (and other file types) with a
single line of code:

My.Computer.Network.DownloadFile(URL, localFilename)
 
Back
Top