0

I have a WebBrowser control, after navigating a page I need to download the image. I used the following code:

HtmlElementCollection tagsColl = webBrowser1.Document.GetElementsByTagName("img");
foreach (HtmlElement currentTag in tagsColl)
{
     ...
     using (var client = new WebClient())
     {
           ...
           client.DownloadFile(currentTag.GetAttribute("src"), path);
           ...
     }
}

but, in this case webclient starts a new session, and link in new session is not correct. I need to do this in same session as webbrowser, only in this case i get a correct link to the image.

How can I do this?

crthompson
  • 15,653
  • 6
  • 58
  • 80
user2808786
  • 15
  • 1
  • 2

1 Answers1

2

Try downloading the image using URLDownloadToFile, which should give you the same session and cache as used by WebBrowser.

noseratio
  • 59,932
  • 34
  • 208
  • 486