C# WebClient download image within url and display the downloaded picture automatically in windows o(曹海涛)

网友投稿 301 2022-08-21

C# WebClient download image within url and display the downloaded picture automatically in windows o(曹海涛)

static void WebClientDownLoad()

{

string url = "http://p4.ssl.cdn.btime.com/t0167dce5a13c3da30d.jpg?size=5012x3094";

WebClient client = new WebClient();

client.DownloadDataCompleted += ClientDownloadDataCompleted;

client.DownloadDataAsync(new Uri(url));

}

private static void ClientDownloadDataCompleted(object sender, DownloadDataCompletedEventArgs e)

{

byte[] imgBytes = e.Result;

using(MemoryStream ms=new MemoryStream(imgBytes))

{

Image img = Image.FromStream(ms);

img.Save("lyf.jpg",ImageFormat.Jpeg);

}

ProcessStartInfo info = new ProcessStartInfo();

info.FileName = "lyf.jpg";

info.UseShellExecute = true;

info.Verb = string.Empty;

Process.Start(info);

}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:.NET 开源项目 Polly 介绍(.net framework 3.5是干嘛的)
下一篇:Linq下有一个非常实用的SelectMany方法,很多人却不会用(linq selectmany)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~