troubleshooting Question

In C# how do I get the full URL from HTMLImgClass?

Avatar of rye004
rye004Flag for United States of America asked on
C#
4 Comments1 Solution52 ViewsLast Modified:
I am writing a program to download images from a web page.  I am able to download the images, but I would also like to log the full path of where it came from.

Below is the code that I have written.

            WebBrowser scrapeWebBrowser = new WebBrowser();

            scrapeWebBrowser.Navigate("http://yahoo.com");

            HTMLDocument objHtmlDocument = (HTMLDocument)scrapeWebBrowser.Document;

            foreach (HTMLImgClass imageElement in objHtmlDocument.images)
            {
                //HTMLImage
                WebClient client = new WebClient();
                string fileName = System.IO.Path.GetFileName(imageElement.href);
                client.DownloadFileAsync(new Uri(imageElement.href), System.IO.Path.Combine(@"L:\temp\imagedownload\", fileName));

                //How do I get the full url for imageElement?
            }

Is it possible to return the full URL from my declared variable imageElement?
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros