Download Files from any WebSite to local path Synchronously

Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 941
We will use WebClient class and its method DownloadFile.This method has two parameters,first parameter is the url of the file we want to download and the second parameter is path to local disk to which we want to save the file.

This method blocks the main thread until the file is downloaded or an error occur in this case the WebException is thrown.

using System.Net;

WebClient webClient = new WebClient();

Comments or Responses

Login to post response