本文实例讲述了C#远程获取图片文件流的方法。分享给大家供大家参考,具体如下: protected void Page_Load(object sender, EventArgs e){ WebRequest myrequest = WebRequest.Create("http://img.558idc.com/uploadfile/
本文实例讲述了C#远程获取图片文件流的方法。分享给大家供大家参考,具体如下:
protected void Page_Load(object sender, EventArgs e) { WebRequest myrequest = WebRequest.Create("http://img.558idc.com/uploadfile/allimg/c/userface.jpg"); WebResponse myresponse = myrequest.GetResponse(); Stream imgstream = myresponse.GetResponseStream(); System.Drawing.Image img = System.Drawing.Image.FromStream(imgstream); //img.Save(Server.MapPath("test.jpg"),System.Drawing.Imaging.ImageFormat.Jpeg); MemoryStream ms = new MemoryStream(); img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Response.ClearContent(); //需要输出图象信息 要修改HTTP头 Response.ContentType = "image/gif"; Response.BinaryWrite(ms.ToArray()); }
更多关于C#相关内容感兴趣的读者可查看本站专题:《C#正则表达式用法总结》及《C#图片操作技巧汇总》
希望本文所述对大家C#程序设计有所帮助。