在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
string filename = Session["file"] as string; string path = Server.MapPath("~/files/" + filename); if (File.Exists(path)) { FileInfo fi = new FileInfo(path); Response.Clear(); Response.ClearHeaders(); Response.ContentType = "application/octet-stream"; Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8).Replace("+", "%20")); Response.AppendHeader("Content-Length", fi.Length.ToString()); Response.WriteFile(fi.FullName); Response.Flush(); Response.End(); } else { Response.Write("文件不存在"); } |
请发表评论