C# 如何将图片读到内存在显示
string str = "C:/Inetpub/wwwroot/pagerror.gif";
FileStream fs = new FileStream(str , FileMode.Open, FileAccess.Read);
byte[] image = new byte[fs.Length];
fs.Read(image, 0, Convert.ToInt32(fs.Length));
fs.Close();
fs.Dispose();
Response.ClearContent();
Response.BinaryWrite(image);
Response.End();
我用上面的方法是可以正确地把硬盘上的图片读到内存中并显示出来,但是如果图片是网站上的图片就不知道怎么显示了,比如
string str = "http://www.scottwilson.com.hk/images/1.jpg";,程序运行后会出错。
其中str是从数据库读出来的,可能是硬盘上的图片,也可能是网站上的图片
请高手指教