using (var client = new WebClient())
{
client.DownloadFile("http://example.com/file/song/a.mpeg", "a.mpeg");
}
using System.Net;
using (WebClient web1 = new WebClient())
web1.DownloadFile("URL", "FileName");
}
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);
}
string folderName = @"C:";
string pathString = System.IO.Path.Combine(folderName, "storefolder");
Directory.CreateDirectory(pathString);
string fileName = System.IO.Path.GetRandomFileName();
pathString = System.IO.Path.Combine(pathString, fileName);
if (!File.Exists(pathString))
{
WebClient webClient = new WebClient();
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);
webClient.DownloadFileAsync(new Uri(@"192.168.75.99Developer shared folderIconschemistrywhite.png"), pathString);
}
else
{
Console.WriteLine("File "{0}" already exists.", fileName);
return;
}