how to download and store web images

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
 
B

Brock Allen

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.
 
S

Steve C. Orr [MVP, MCSD]

In VB2005 you can download and store images (and other file types) with a
single line of code:

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top