1st Nov, 2007

Downloading files using System.Net.WebClient

The other day I wanted to save images on my local hard disk that were accessible via a URL. Initially I thought about getting an HttpResponse and pass it to the Image.FromStream method. The Save method on the System.Drawing.Image object would have done the job of saving the file to the hard disk.

However, I found out that the System.Net.WebClient already has a helper method called DownloadFile. The parameters that you need to pass in are the url of the resource, and the path where to save the file locally. Easy as pie!

Have you ever been to Malta? All you need to know is a click away! Malta Travel Guide, Bargain Accommodation in Malta, Malta Hotels

Responses

Ah, thanks mate! This is exactly what I’ve been searching for!

Leave a response

Your response:

Categories