C# 通过URL获取图片并显示在PictureBox上的方法
根据服务器返回的图片路径,将相应的图片显示在客户端的界面上
1 string url = string.Format(@"http://webservice.36wu.com/DimensionalCodeService.asmx/GetCodeImgByString?size={0}&content={1}", 5, 123456); 2 System.Net.WebRequest webreq = System.Net.WebRequest.Create(url); 3 System.Net.WebResponse webres = webreq.GetResponse(); 4 using(System.IO.Stream stream = webres.GetResponseStream()) 5 { 6 pictureBox1.Image = Image.FromStream(stream); 7 }