Download a resource using WebClient in C#.NET
using System.net;
//download a resource from the internet.
private void downloadResource() {
WebClient wc= new WebClient();
string uri = "http://computerbapu.blogspot.com";
string fname = "myResource.txt";
try {
//this function does the work
wc.DownloadFile(uri, fname);
}
catch (WebException exc)
{
Console.WriteLine(exc);
}
catch (UriFormatException exc)
{
Console.WriteLine(exc); }
Console.WriteLine("Download is completed.");
}
No comments:
Post a Comment