如何从网址下载图片 [英] How download image from url

查看:81
本文介绍了如何从网址下载图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我有一个网址:-http://resources.printofast.com/media/bdccb931-1599-4eba-817d-6b3968ab90ee.jpg



我想使用asp.net原样下载此图片。



请让我知道因为我无法做到。



非常感谢



我尝试过:



1. string url = @http://resources.printofast.com/media/bdccb931-1599-4eba-817d-6b3968ab90ee.jpg ;

WebClient客户端=新的WebClient();

client.DownloadFileCompleted + = new AsyncCompletedEventHandler(client_DownloadFileCompleted);



client.DownloadFileAsync(new Uri(url),@c:\\ \\ temp\image35.png);

解决方案

试试这个



  string  url =   http:// resources .printofast.com /媒体/ bdccb931-1599-4eba-817d-6b3968ab90ee.jpg; 
WebClient webClient = new WebClient();
string path = Server.MapPath( 图像); // 在根目录中创建名为Images的文件夹
string fileName = Path.GetFileName(url);
webClient.DownloadFile(url,path + \\ + fileName);


Hi ,

I have an url :-http://resources.printofast.com/media/bdccb931-1599-4eba-817d-6b3968ab90ee.jpg

I want to download this image using asp.net as it is .

Please let me know as i am unable to do it .

Many thanks

What I have tried:

1. string url = @"http://resources.printofast.com/media/bdccb931-1599-4eba-817d-6b3968ab90ee.jpg";
WebClient client = new WebClient();
client.DownloadFileCompleted += new AsyncCompletedEventHandler(client_DownloadFileCompleted);

client.DownloadFileAsync(new Uri(url), @"c:\temp\image35.png");

解决方案

try this

string url = "http://resources.printofast.com/media/bdccb931-1599-4eba-817d-6b3968ab90ee.jpg";
           WebClient webClient = new WebClient();
           string path = Server.MapPath("Images") ; // Create a folder named 'Images' in your root directory
           string fileName = Path.GetFileName(url);
           webClient.DownloadFile(url, path + "\\" + fileName);


这篇关于如何从网址下载图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆