如何在asp.net 4.0中压缩文件夹并下载c# [英] How to zip a folder and download in asp.net 4.0 c#
本文介绍了如何在asp.net 4.0中压缩文件夹并下载c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个图片库页面,其中有下载选项。有一个包含图像文件的文件夹。当用户单击页面上的下载选项时,我希望ASP.NET将包含所有图像文件的文件夹压缩到临时的.zip文件夹中。然后客户端将从服务器下载它。当用户的下载完成后,临时Zip文件应该自行删除。
I have a image gallery page where there are download options. There is a folder containing image files. When a user clicks the download option on the page, I want ASP.NET to zip the folder with the all images files into a temporary .zip folder. Then the client will download it from the server. When the user''s download is finished, the temporary Zip file should delete itself.
推荐答案
dotnetzip库非常丰富,可以创建zip文件
http://dotnetzip.codeplex.com/ [ ^ ]
dotnetzip library is very rich for to create zip files
http://dotnetzip.codeplex.com/[^]
using (ZipFile zip = new ZipFile())
{
// add this map file into the "images" directory in the zip archive
zip.AddFile("c:\\images\\personal\\7440-N49th.png", "images");
zip.Save(Response.OutputStream);
}
这篇关于如何在asp.net 4.0中压缩文件夹并下载c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文