日期:2014-05-18  浏览次数:20900 次

picturebox无法显示一个网络图片
图片连接是http://img.***.com/cgi-bin/personal/agetimg.cgi?request=23000000fc058ef58c5242ceed730c076785f49de0b6e926fd91b4a20aee859babc8a2507e8753c509805266 是根据请求画出的一个图片,我用imagelocation无法显示图片,但直接打开正常,请问解决办法,为什么会这样

------解决方案--------------------
用WebRequest方法(这个网络路径下)下载流 
Bitmap构造方法接受该流
C# code

using   System.IO; 
using   System.Net; 


HttpWebRequest   vHttpWebRequest   =   (HttpWebRequest)WebRequest.Create( 
       @ http://img.***.com/cgi-bin/personal/agetimg.cgi?request=23000000fc058ef58c5242ceed730c076785f49de0b6e926fd91b4a20aee859babc8a2507e8753c509805266"); 
HttpWebResponse   vHttpWebResponse   =   (HttpWebResponse)vHttpWebRequest.GetResponse(); 
BinaryReader   vBinaryReader   =   new   BinaryReader(vHttpWebResponse.GetResponseStream()); 
MemoryStream   vMemoryStream   =   new   MemoryStream(); 
byte[]   vBuffer   =   new   byte[0x1000]; 
int   vReadLength   =   vBinaryReader.Read(vBuffer,   0,   vBuffer.Length); 
while   (vReadLength   >   0) 
{ 
       vMemoryStream.Write(vBuffer,   0,   vReadLength); 
       vReadLength   =   vBinaryReader.Read(vBuffer,   0,   vBuffer.Length); 
} 
vHttpWebResponse.Close(); 
vMemoryStream.Position   =   0; 
pictureBox1.Image   =   Bitmap.FromStream(vMemoryStream); 
vMemoryStream.Close();