//引用IO、TEXT
protected void dFile()
{string path = Server.MapPath("../") + "UploadFile\\" + filecode.Value;
//初始化 FileInfo 类的实例,它作为文件路径的包装
FileInfo fi = new FileInfo(path);
//判断文件是否存在
if (fi.Exists)
{
//将文件保存到本机上
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fi.Name));
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream,charset=gbk";
Response.ContentEncoding = Encoding.GetEncoding("gb2312");
Response.Filter.Close();
Response.WriteFile(fi.FullName);
Response.End();
}
else
{
ZWL.Common.MessageBox.Show(this, "对不起,没有相关文件!");
}
}