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");

static void MyDownload() {
using (WebClient MyWebClient = new WebClient())
try {
MyWebClient.Proxy = null;
MyWebClient.DownloadFile("", "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.



No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: