Click here to Skip to main content
12,560,367 members (54,628 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP .NET
Hi all,

I have a windows application with a Web Browser control in it.
There are hundreds of links in that web page, each linking to different documents.
On the click of every link, the document loads in the same webpage.

Now here is the question:
Is there a way so that after the web page is loaded completely, each of the link click event in the page is raised and hence the corresponding documents (which is nothing but 'href' of the links) are saved in a specified location in the computer.
[either through threading or else one after another]

Below is a little progress from my side.

protected void doc_completed(object sender, WebBrowserDocumentCompletedEventArgs e)
           HtmlElementCollection mylinks = mywebBrowser.Document.GetElementsByTagName("A");
Posted 29-Sep-12 10:59am
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You can always use Html Agility Pack.

HtmlWeb hw = new HtmlWeb();
 HtmlDocument doc = hw.Load(/* url */);
 foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href]"))
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

I used the asyn file download function to download all the files that were linked in the web page.

foreach(HtmlElement single_link in mylinks)
 WebClient client = new WebClient();
 client.DownloadFileAsync(new Uri("SomeURLToFile"),"SomePlaceOnLocalHardDrive");

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161026.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100