首页 > Windows开发 > 详细

C# WebClient download image within url and display the downloaded picture automatically in windows os

时间:2020-03-18 10:46:27      阅读:51      评论:0      收藏:0      [点我收藏+]
原文:C# WebClient download image within url and display the downloaded picture automatically in windows os

技术分享图片
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);
        }
技术分享图片

 

C# WebClient download image within url and display the downloaded picture automatically in windows os

原文:https://www.cnblogs.com/lonelyxmas/p/12514961.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!