image控件如何显示数据库中的图片 asp.net



//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";
posted @ 2013-01-27 20:10  金虹巴巴  阅读(729)  评论(0编辑  收藏  举报