if (!Page.IsPostBack)
{
string address = Request["address"].ToString();
//string httpaddr="files/"+address;
address = Server.MapPath("files/") + address;
//Response.Write(address);
System.IO.FileInfo fi = new System.IO.FileInfo(address);
if (System.IO.File.Exists(address))
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Filter.Close();
Response.WriteFile(fi.FullName);
Response.End();
//Response.WriteFile(httpaddr);
//Response.Write();
}
else
{
Response.Write("<script>alert('文件不存在!')</script>");
}
}
down下载
最新推荐文章于 2024-08-14 18:00:11 发布