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();
webClient.DownloadFile("http://domainname.com/file.txt",@"d:\file.txt");