简体   繁体   中英

How do I save an Image from an url?

How do I take an image from an url and save it locally?

http://someurl.com/imagename.jpg -> c:\\apppath\\imgfolder

ASP.NET C#

I am not very good with IO stuff, hope someone can help me out :)

Try this.

System.Net.WebClient wc = new System.Net.WebClient();

wc.DownloadFile("http://www.domin.com/picture.jpg", @"C:\Temp\picture.jpg");

Since you've tagged this with ASP.NET, it's worth pointing out that if you put this code in your ASP.NET Website/Web Application, you'll need to make sure the the Identity/Account that your application is running as, has permission to write the file to the file system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM