62,046
社区成员
发帖
与我相关
我的任务
分享
FileInfo fi = new FileInfo(destFileName);
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = false;
if (filename == String.Empty)
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + Path.GetFileName(destFileName));
else
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + filename + UtilsFile.GetFileType(destFileName));
HttpContext.Current.Response.AppendHeader("Content-Length", fi.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.WriteFile(fi.FullName);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();