joomla visitors
Mithila Software Blog | How to download an image directly to the disk in asp.net

How to download an image directly to the disk in asp.net

April 01, 2013 Posted by Mithila Software

With just a couple line of codes you can download an image from internet onto your pc with the asp.net code below.

 if(Directory.Exists(@"c:\localpath"))
{ localFilename = @"c:\localpath\tofile.jpg"; }
else { Directory.CreateDirectory(@"c:\localpath");
localFilename = @"c:\localpath\tofile.jpg"; }
using (WebClient client = new WebClient())
{
client.DownloadFile(http://cs316628.userapi.com/v316628767/56f7/FqFPYSd-0fg.jpg, localFilename);
}

The above code requires two references System.IO and System.Net

Tags:

Asp.Net

blog comments powered by Disqus
Address ::
Mithila Software Solutions,
Green House , 3 GM Road ,
Near Radio Station , Darbhanga
PIN:: 846004
Phone :: # 099-397-49350