C# WebClient download image within url and display the downloaded picture automatically in windows os
程序员文章站
2022-09-27 13:37:15
static void WebClientDownLoad() { string url = "http://p4.ssl.cdn.btime.com/t0167dce5a13c3da30d.jpg?size=5012x3094"; WebClient client = new WebClient( ......
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); }