现在的位置: 首页 > 综合 > 正文

读取并显示以二进制的格式存储到数据库中图片

2013年10月12日 ⁄ 综合 ⁄ 共 512字 ⁄ 字号 评论关闭

 Image1.Visible=true;

SqlConnection con=new SqlConnection();

string imagename="";

try

{

con.Open();

SqlCommand com=new SqlCommand();

SqlDataReader dr=com.ExecuteReader();

dr.Read();

MemoryStream ms=new MemotyStream((Byte[])dr["name"]);

Bitmap img=new Bitmap(ms);

string filepath=Server.MapPath("Files/");

DirectoryInfo dir=new DirectoryInfo(filepath);

FileInfo[] filecount=dir.GetFiles();

int i=filecount.Length;

imagename=filepath+((i+1)+".jpg");

image.Save(imagename);

dr.close();

Image1.ImageUrl="Files/"+((i+1)+".jpg");

}

finally

{

con.Close();

}

抱歉!评论已关闭.