Code
if (ViewState["AttFileTable"] != null)
{
DataTable dt_a = (DataTable)ViewState["AttFileTable"];
DataRow[] rows = dt_a.Select("fileID=" + 文件ID);
if (rows.Length > 0)
{
byte[] filebyte = (byte[])rows[0]["fileContent"];//二进制字段内容
string fileName = rows[0]["realName"].ToString();
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));//设置编码,解决下载文件名乱码
Response.AppendHeader("Content-Length", filebyte.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.OutputStream.Write(filebyte, 0, filebyte.Length);
Response.End();
}
else
{
cls_Common.alert("不存在");
}
}
posted @
2009-11-03 10:10
风w
阅读(
753)
评论()
编辑
收藏
举报