zoukankan      html  css  js  c++  java
  • 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);
            }
  • 相关阅读:
    作业6
    作业8
    作业7
    作业5
    作业4
    作业3
    作业2
    作业1
    浏览器跨域的细节
    解析node-cors模块
  • 原文地址:https://www.cnblogs.com/Fred1987/p/12511961.html
Copyright © 2011-2022 走看看