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

高分求如何以流方式输出图片!
我现在硬盘上已有一图片
并知道了地址

现在想用流的方式把这个图片文件输出到页面。

现在找到一种方法,但是在输出的时个要指定一个图片类型,我想找一种不要指定的

只要是图片就行的   如:image/*   这种

但不知道具体怎么弄。。

刚进来验证码5个88888,呵呵,多弄点分上来



------解决方案--------------------
/// <summary>
/// 图片以二进制流输出
/// </summary>
private void BindData()
{
FileStream fs = new FileStream(@ "D:\22-11-46-3-524454584.jpg ",FileMode.Open,FileAccess.Read);
byte[] mydata = new byte[fs.Length];
int Length = Convert.ToInt32(fs.Length);
fs.Read(mydata,0,Length);
fs.Close();
this.Response.OutputStream.Write(mydata,0,Length);
this.Response.End();
}
}

------解决方案--------------------
http://blog.csdn.net/zhangshg2008/archive/2007/02/02/1501140.aspx
可能会对你有用
------解决方案--------------------
对于 image ,我测试过了,

指定 Response.ContentType = "application/octet-stream ";