我如何从一个URL保存图像? [英] How do I save an Image from an url?
本文介绍了我如何从一个URL保存图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要如何拍摄图像从URL,并将其保存在本地?
How do I take an image from an url and save it locally?
http://someurl.com/imagename.jpg
- > C:\\ APPPATH \\ imgfolder
http://someurl.com/imagename.jpg -> c:\apppath\imgfolder
ASP.NET C#
ASP.NET C#
我不是很好的IO的东西,希望有人能帮助我:)
I am not very good with IO stuff, hope someone can help me out :)
推荐答案
试试这个。
System.Net.WebClient wc = new System.Net.WebClient();
wc.DownloadFile("http://www.domin.com/picture.jpg", @"C:\Temp\picture.jpg");
既然你已经标记了这个与ASP.NET,这是值得指出的是,如果你把这个code在ASP.NET网站/ Web应用程序,你需要确保的身份/帐户您的应用程序运行的,有权限将文件写入到文件系统。
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.
这篇关于我如何从一个URL保存图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文