Click here to Skip to main content
Rate this: bad
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
0 OriginalGriff 310
1 Sergey Alexandrovich Kryukov 176
2 PhilLenoir 164
3 Richard MacCutchan 160
4 Sharmanuj 156
0 Sergey Alexandrovich Kryukov 6,081
1 OriginalGriff 5,115
2 CPallini 2,473
3 Richard MacCutchan 1,597
4 Abhinav S 1,505

Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2014
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