导出文件:
string filePath = Server.UrlDecode(filePath);
if (File.Exists(filePath))
{
FileInfo fi = new FileInfo(filePath);
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(Path.GetFileName(filePath), System.Text.Encoding.UTF8));
Response.AppendHeader("Content-Length", fi.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(filePath);
Response.Flush();
Response.End();
}
转载于:https://www.cnblogs.com/johnblogs/p/6709074.html