日期:2014-05-17 浏览次数:20491 次
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = DateTime.Now.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
string StrsqlOne = "select P_PersonnelInformation.CardNo,Name,Sex,Age,Addr,Phone,EventTime,Photo from P_PersonnelInformation inner join P_EventLog on P_PersonnelInformation.CardNo=P_EventLog.CardNo and P_EventLog.ID in(select max(ID) from P_EventLog) where EventTime>'2013-01-11'";
DataTable dt = DbHelper.Instance.CreateDataTable(StrsqlOne);
byte[] buffByle = (Byte[])dt.Rows[0]["Photo"];
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();