如何压缩现有文件夹以进行下载而不保存压缩文件夹 [英] How do you zip an exsisting folder for download without saving the zipped folder

查看:87
本文介绍了如何压缩现有文件夹以进行下载而不保存压缩文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆用户通过压缩文件上传的文件夹.我提取文件夹内容,创建一个新文件夹,然后将内容保存到硬盘驱动器上的文件夹中.

我目前保存了原始的压缩文件夹和提取的内容,但这不是一个好方法,因为如果他们要删除或移动提取的文件中的内容,将不会反映在最初上传的已压缩压缩文件中.

当用户请求文件夹的内容时,我会向他们提供原始的压缩文件,但是如您所见,如果他们对提取的内容进行了更改,则会出现问题.

我正在尝试查看是否有一种方法可以压缩提取的文件夹并将新压缩的文件夹呈现给客户端以供下载,而无需保存新压缩的文件夹.

任何帮助将是一个很大的帮助.在此先感谢您.

解决方案

您可以使用该库对文件夹进行ZIP或UNZIP压缩:

http://sharpdevelop.net/OpenSource/SharpZipLib

它是开放源代码,完全用C#编写. ="http://sharpdevelop.net/OpenSource/SharpZipLib/" target ="_ blank" title ="New Window"> ^ ]快速压缩文件夹并将其呈现给用户.

在某些情况下,一段时间(例如5分钟)后删除文件可能很有意义,这样,如果用户出于任何原因尝试两次下载文件,则不必重新创建原始文件zip文件.


I have a bunch of folders that users have uploaded via a zipped file. I extract the folder contents create a new folder and save the contents to the folder on the hard drive.

I currently save the original zipped folder and the extracted content but that is not a good method because if they wanted to delete or move content around in the extracted files it would not reflect in the saved zipped that was originally uploaded.

When a user request the contents of the folder I feed them the original zipped file but as you can see there is a problem if they made changes to the extracted content.

I am trying to see if there is a way to zip the extracted folder and present the newly zipped folder to the client for download without saving the newly zipped folder.

Any help would be a great help. Thanks in advance.

解决方案

You can ZIP or UNZIP the folder with that library:

http://sharpdevelop.net/OpenSource/SharpZipLib

It''s OpenSource and entirely wrote in C#


Use SharpZipLib[^] to zip your folder on the fly and present it to the user.


In some case, it might make sense to delete files after a while (say 5 minutes) so that if the user try to download it twice for any reason you won''t have to recreate the original zip file.


这篇关于如何压缩现有文件夹以进行下载而不保存压缩文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆