Programmatically download file form web using C#

/// <summary>

/// This method downloads a file form internet url.

/// </summary>

void DownloadDotNetFramework()


    string OutPutpath = @”C:\DownlodedRtf.rtf”;

    WebClient oWebClient = new WebClient();

    string url = @”;;

    //Add callback function which will call after download complete.

    oWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(oWebClient_DownloadFileCompleted);

    oWebClient.DownloadFileAsync(new Uri(url), OutPutpath);



/// <summary>

/// Method which will call after completion of download.

/// </summary>

/// <param name=”sender”></param>

/// <param name=”e”></param>

void oWebClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)


    MessageBox.Show(“File downloaded.”);



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: