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!
.NET ProgrammingC#* WPF

Avatar of undefined
Last Comment
Ryan Chong
ASKER CERTIFIED SOLUTION
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of rye004
rye004
Flag of United States of America image

ASKER

Thanks!  I did have to set the property for “Embedded Interop Types” to “False” under the reference for Microsoft.mshtml.
Avatar of Ryan Chong
Ryan Chong
Flag of Singapore image

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!
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo