giovedì 19 giugno 2008

Download a file in C#

Do you want to download a file? This file is situated in Internet and you don't know how to do? .NET Framework helps you.

We make an example: the file that we want to download is: http://www.google.it/intl/it_it/images/logo.gif. This is an image, the Google's logo.

The code is this:

WebClient() client = new WebClient();

client.DownloadFile(@" http://www.google.it/intl/it_it/images/logo.gif", @"C:\logo.gif");

WebClient is a class situated in System.Net. The first parameter is the file's position. The second is the filename, where it saves the file on our hard disk.

It is very easy, no?


0 commenti: