从阅读文档开始:
https://msdn.microsoft.com/en-us/library/ms524632(v=vs.90).aspx
.
MapPath
基于相关路径或虚拟路径生成物理路径,因此给它一个物理路径是没有意义的。你已经有了物理路径,所以你应该能够完全跳过这一步。
protected void btnDownloadExcelTemp_Click(object sender, EventArgs e)
{
try
{
string strFileFormat = System.Configuration.ConfigurationManager.AppSettings["FormateFilePath"].ToString();
string strFilePath = strFileFormat + "/CMP_TEMPLATES.xlsx";
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.AppendHeader("content-disposition", "attachment; filename=" + "CMP_TEMPLATES.xlsx");
response.ContentType = "application/octet-stream";
response.WriteFile(strFilePath);
response.Flush();
response.End();
}
catch (Exception)
{
throw;
}
}