我在文件夹中创建了一个文本文件并压缩了该文件夹并保存了@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文件.