日期:2014-05-17 浏览次数:20379 次
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();