Link to home
Start Free TrialLog in
Avatar of rye004
rye004Flag for United States of America

asked on

How do I download all images from a web page in C# using WPF?

I am trying to write a program using C# and WPF to download all images from a web page.

In my XAML I added the following control:

<WebBrowser x:Name="scrapeWebBrowser" Grid.Column="1" Grid.Row="1"/>

Open in new window


For testing, I created a test button that does the following:

scrapeWebBrowser.Navigate("http://yahoo.com");
HTMLDocument objHtmlDocument = (HTMLDocument)scrapeWebBrowser.Document;

foreach (IHTMLElementCollection imageElements in objHtmlDocument.images)
{
//I am not sure what to do here.  I am trying to get the reference to the image.
}

Open in new window


How do I get a reference in my code above?  Once I have the reference, how do I download it?

Any direction would be greatly appreciated.      

Many Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore 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 rye004

ASKER

Thanks!  I did have to set the property for “Embedded Interop Types” to “False” under the reference for Microsoft.mshtml.
I did have to set the property for “Embedded Interop Types” to “False” under the reference for Microsoft.mshtml.

yes, you're correct on that!