Solved

Save images from WebBrowser/IHTMLDocument

Posted on 2003-11-14
3
1,196 Views
Last Modified: 2009-07-29
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
0
Comment
Question by:fieldofasphodel
  • 2
3 Comments
 
LVL 10

Expert Comment

by:ptmcomp
ID: 9754302
Yes, since you already downloaded the images you can get them from the browser cache.
0
 
LVL 10

Accepted Solution

by:
ptmcomp earned 500 total points
ID: 9754395
Here is a link:
http://www.graphcomp.com/info/specs/ms/inetr007.htm

But when you don't explicitly bypass the cache you should get it from the cache anyway.
0
 

Author Comment

by:fieldofasphodel
ID: 9765373
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.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now