SqlConnection cn = new SqlConnection();//数据库链接
cn.Open();
SqlDataAdapter da2 = new SqlDataAdapter("select * from myfile where id= 24 ", cn);//读出数据库中相应的数据
DataSet ds2 = new DataSet();
da2.Fill(ds2);
byte[] b2 = (byte[])ds2.Tables[0].Rows[0]["files "];
string type = (string)ds2.Tables[0].Rows[0]["type "];
Response.Clear();
string Type = checktype(type);
Response.AddHeader("Content-Disposition", "attachment; filename=下载" + type);
Response.AddHeader("Content-Length ", b2.Length.ToString());
Response.ContentType = Type;
Response.BinaryWrite(b2);
Response.End();
string FileName = ((LinkButton)sender).CommandArgument;
Response.Clear();
Response.ContentType = Type;
Response.AddHeader("Content-Disposition", "attachment;FileName= " + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8));
Response.WriteFile(FileName);
Response.End();
下载文件
最新推荐文章于 2024-09-22 11:17:00 发布