Download File using Dot Net

In this post, I will demonstrate how easy it is to download a file from a web server to your local hard drive. In most scenarios, you may browse the net using your web browser and click on a hyperlink to start a downloading of a file from a remote site.
Some of you may be interested in how to download this using their application code using Dot Net.
This can be very easily achieved using the WebClient class under System.Net namespace.

First, import the System.Net namespace.

using System.IO;

The above LOC will do so.

Now, create an instance of WebCleient class.

WebClient client = new WebClient();

Now, call the DownloadFile method

client.DownloadFile(<url>, @"<fileDestinationName>.<filetype>");


Have fun. Cheers !!!!

Comments

Popular posts from this blog

Encrypt and Decrypt Images Using Java

Build your own Network sniffer

ASP Response.Write newline