【发布时间】:2014-03-20 14:10:44
【问题描述】:
当我尝试下载具有全名的文件时,它无法下载。但是在一个参数中,我将参数作为文件名发送。文件路径是自动生成的。
下载文件名为:Update_4_Product(截图所示)
实际文件名是:Update_4_Product Details.xlsx
这是我的代码
private void DownloadUploadDataTemplate(string fileName)
{
string Outgoingfile = fileName + ".xlsx";
string targetDirectory = Path.GetDirectoryName(XTP.Caching.AppSettingCache.GalleryFilePath) + @"\" + this.TenantCode + "\\Files" + @"\" + Outgoingfile;
System.IO.FileInfo file = new System.IO.FileInfo(targetDirectory);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/vnd.ms-excel";
Response.WriteFile(file.FullName);
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
else
{
this.MessageLabel.Text = "File Not Found";
}
}
谁能告诉我我的代码有什么问题。
【问题讨论】:
标签: asp.net excel c#-4.0 download