c# download a file from web code example

Example 1: c# download file

using System.Net;

using (WebClient web1 = new WebClient())
	web1.DownloadFile("URL", "FileName");
}

Example 2: c# download file

string remoteUri = "http://www.contoso.com/library/homepage/images/";
string fileName = "ms-banner.gif", myStringWebResource = null;

// Create a new WebClient instance.
using (WebClient myWebClient = new WebClient())
{
    myStringWebResource = remoteUri + fileName;
    // Download the Web resource and save it into the current filesystem folder.
    myWebClient.DownloadFile(myStringWebResource, fileName);        
}