小编use*_*336的帖子

使用DotNetZip通过ASP.NET MVC下载zip文件

我在文件夹中创建了一个文本文件并压缩了该文件夹并保存了@same位置以供测试.我想在创建后直接在用户计算机上下载该zip文件.我正在使用dotnetzip库并完成以下操作:

Response.Clear();
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + "sample.zip");
using (ZipFile zip = new ZipFile())
{
    zip.AddDirectory(Server.MapPath("~/Directories/hello"));
    zip.Save(Server.MapPath("~/Directories/hello/sample.zip"));
}
Run Code Online (Sandbox Code Playgroud)

有人可以建议如何在用户端下载zip文件.

c# dotnetzip asp.net-mvc-5

9
推荐指数
2
解决办法
4万
查看次数

标签 统计

asp.net-mvc-5 ×1

c# ×1

dotnetzip ×1