image控件如何显示数据库中的图片 asp.net
3个回答
展开全部
试下这段代码~我是这样实现的
//byte[] buffByle = (Byte[])prtb.Rows[0]["sPicture"];//把数据库中图片的二进制数据转换一个byte数组
//int filelength = buffByle.Length;//获得数组的长度
////创建在服务器上对应虚拟路径的物理路径
////string myUrl = HttpContext.Current.Server.MapPath(this.Request.ApplicationPath) + "TempDownLoad";
//System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("TempDownLoad"));
//if (file.Exists)
//{
// file.Delete();
//}
//string myUrl = Server.MapPath("TempDownLoad");
//// 创建文件流
//FileStream fs = new FileStream(myUrl, FileMode.OpenOrCreate);
//BinaryWriter w = new BinaryWriter(fs);//以二进制的形式将基元内写入流
//w.BaseStream.Write(buffByle, 0, filelength);//把数据库中的图片二进制添加到BinaryWriter
//w.Flush();
//w.Close();
//Image1.ImageUrl = "~/TempDownLoad";
//byte[] buffByle = (Byte[])prtb.Rows[0]["sPicture"];//把数据库中图片的二进制数据转换一个byte数组
//int filelength = buffByle.Length;//获得数组的长度
////创建在服务器上对应虚拟路径的物理路径
////string myUrl = HttpContext.Current.Server.MapPath(this.Request.ApplicationPath) + "TempDownLoad";
//System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("TempDownLoad"));
//if (file.Exists)
//{
// file.Delete();
//}
//string myUrl = Server.MapPath("TempDownLoad");
//// 创建文件流
//FileStream fs = new FileStream(myUrl, FileMode.OpenOrCreate);
//BinaryWriter w = new BinaryWriter(fs);//以二进制的形式将基元内写入流
//w.BaseStream.Write(buffByle, 0, filelength);//把数据库中的图片二进制添加到BinaryWriter
//w.Flush();
//w.Close();
//Image1.ImageUrl = "~/TempDownLoad";
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询