asp.net??杩???浠朵?杞芥?灏????″?ㄤ?????瀹?璺?寰???浠朵?瀛??版???版??瀹?浣?缃?
1??璇存??
??????杩???浠朵?杞芥?瀹??闆????″?ㄤ?????浠朵?杞藉?版???版??瀹?浣?缃???杩?????瑕???瀹????″?ㄦ??浠惰礬寰?
try
{
string strFilePath = Server.MapPath("~") + "/excel/20170206104654.xlsx";//???″?ㄦ??浠惰礬寰?
FileInfo fileInfo = new FileInfo(strFilePath);
Response.Clear();
Response.Charset = "GB2312";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(fileInfo.Name));
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.ContentType = "application/x-bittorrent";
Response.WriteFile(fileInfo.FullName);
Response.End();
}
catch (System.Threading.ThreadAbortException ex)
{
//涓???澶???
}
catch (Exception ex)
{
//??澶???
}
![](https://img.laitimes.com/img/_0nNw4CM6IyYiwiM6ICdiwiIx0DciV2dmADM30zd-cmbw5CRzUyYtJ2d1kWT6VEVNpXUE9EMJRVT0tmaNl3ZU1keVRUT4lFRNlXQ65EeBpWT0FkaONTVq1UM4kWT3NGVNdXS6x0dZpnTxkEVOZ3YyI2cKJDT0ljMZVXTzold41WW15UbMFTRE1UeNhlWuZ0ViBXO5xkNNh0YwIFSh9CXt92YuM3YltWas5iclN3Ztl2Lc9CX6MHc0RHaiojIsJye.png)
?