1

I have been using some code to download various MIME types such as MP3s (see below) but I can't get it working for Zip files. Here is my code, can anybody tell me where I am going wrong, I have tried both with the commented line and without and both times I get a 'file not found' type error :

[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);
    }

EDIT : It seems like the Zip files are being changed to Rar files because WinRar is installed on the server, is there anything I can do about this apart from uninstalling WinRar?

4

1 回答 1

0

您怎么知道您的 ZIP 文件已更改为 RAR 文件?

是不是因为当你下载文件时会弹出 WinRar 窗口,因为你有*.zip与 WinRar 关联的文件扩展名?

您是否确认这Path.Combine(downloadPath, fileName)确实一个 zip 文件?

于 2012-06-07T10:07:45.093 回答