1
我一直在使用一些代码来下载各种MIME类型,如MP3(见下文),但我无法让它在Zip文件中工作。这里是我的代码,任何人可以告诉我,我错了,我已经用注释行,并没有尝试都和两次我得到一个“找不到文件”错误类型:为zip文件创建文件下载功能
[Authorize]
public virtual FileResult DownloadZip(string fileName)
{
var downloadPath = Server.MapPath("~/Content/Downloads/");
//fileName = Path.ChangeExtension(Path.GetFileName(fileName), "zip");
var file = Path.Combine(downloadPath, fileName);
return File(file, "application/zip", fileName);
}
编辑:看来就像Zip文件被更改为Rar文件,因为WinRar安装在服务器上,除卸载WinRar之外,有什么我可以做的吗?
我会从调试方法开始,在注释行之后检查'fileName'里面的内容(取消注释),它会产生正确的路径吗? – Alex