Link to home
Start Free TrialLog in
Avatar of fieldofasphodel
fieldofasphodel

asked on

Save images from WebBrowser/IHTMLDocument

Hi,
I'm writing an application that uses a WebBrowser control to save webpages for offline reading. I am able to get at the html source fine and save that, but getting the images is proving to be tricky. Currently, I get a list of the of images from the Document property, by looping through each IHTMLImgElement in the Document.Images element collection. That gives me the name and the final url for the image, so I use a WebRequest to download the image.

I feel there is a better way to get these images. The WebBrowser control has already downloaded these images to display them and I don't like having to download each image twice, it seems like a big waste of resources. Is there anyway to get each image from the WebBrowser control, by extracting it from the DOM or something?

Anyone who can point me to an MSDN or other article on how to extract this information, or provides a code example will get the points.

Thanks
Avatar of ptmcomp
ptmcomp
Flag of Switzerland image

Yes, since you already downloaded the images you can get them from the browser cache.
ASKER CERTIFIED SOLUTION
Avatar of ptmcomp
ptmcomp
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fieldofasphodel
fieldofasphodel

ASKER

Thanks, this will help out a lot. I'd rather explicitly get my images from the cache, it's very important to my project that I don't get the image from the server twice. Using this rather than assuming my WebRequest is getting cached images gives me that reassurance.