if (Request.QueryString["filepath"] != null)
{
string path = Request.QueryString["filepath"].ToString();
FileInfo fi = new FileInfo(path);//获取文件路径
string name = Request.QueryString["filename"];//获取附件原名
if (fi.Exists)//判断文件是否存在
{
//将文件保存到本机上
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(name));
Response.AddHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Filter.Close();
Response.WriteFile(fi.FullName);
Response.End();
}
else
{
pubfun.Alert(Page, "您要下载的文件不存在!");
pubfun.RegisterStartupScript(Page, "PAGE", "window.location.href='" + "DownList.aspx?ChannelId=9';");
}
}
else
{
pubfun.Alert(Page, "请选择您要下载的文件!");
pubfun.RegisterStartupScript(Page, "PAGE", "window.location.href='" + "DownList.aspx?ChannelId=9';");
}
附件下载
最新推荐文章于 2024-06-02 16:33:25 发布
