How to download web pages
Download the web page from the particular website using the
following code.
The following code is used to download the .html page from the web site.
We are using the class WebClient. This class is used to download the page from the website
using System;
using System.Net;
using System.Threading;
class MyThread {
static void Main() {
new Thread(MyDownload).Start();
Console.WriteLine("downloading the page.. Please wait");
Console.ReadLine();
}
static void MyDownload() {
using (WebClient MyWebClient = new WebClient())
try {
MyWebClient.Proxy = null;
MyWebClient.DownloadFile("http://www.dotnetspider.com", "MyPage.html");
Console.WriteLine("Download completed");
}
catch (Exception ex)
{
}
}
}
The above code will clearly show you the process of the WebClient to download the file.
By
Nathan