当前位置: 移动技术网 > IT编程>开发语言>c# > C# WebClient download image within url and display the downloaded picture automatically in windows os

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

2020年03月18日  | 移动技术网IT编程  | 我要评论
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);
        }

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网