简体   繁体   English

使用zipstorer类压缩包含子文件夹的文件夹

[英]Zip a folder having subfolders using zipstorer class

I am using ZIpstorer class library to compress files. 我正在使用ZIpstorer类库来压缩文件。 I am able to zip a file by calling zip.AddFile procedure. 我可以通过调用zip.AddFile过程来压缩文件。 But I want to zip folders which has subfolders too. 但是我也想压缩包含子文件夹的文件夹。 So the resulting zip file should have folder and subfolder structure inside the zip file normally. 因此,生成的zip文件通常应在zip文件内部具有文件夹和子文件夹结构。 I am not able to do it. 我做不到。 if i process each file by looping all folders and sub folders and then if call zip.Addfile then it will result in zip file with all the files inside it without a directory structure. 如果我通过循环处理所有文件夹和子文件夹来处理每个文件,然后调用zip.Addfile那么它将导致zip文件及其内部的所有文件都没有目录结构。

So how can i zip a folder using Zipstorer class . 因此,如何使用Zipstorer类压缩文件夹。 What changes i have to do? 我必须做些什么?

You can use (back)slashes for the _filenameInZip (sic) parameter to add files in a directory in the zip: 可以对_filenameInZip (sic)参数使用(反)斜杠,以在zip目录中添加文件:

zip.Addfile(,,"directory/filename.txt",);

Or 要么

zip.Addfile(,,"directory\\filename.txt",);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用ZipStorer的手动zip创建问题 - Manual zip-creation issue using ZipStorer 使用ZipOutputStream压缩子文件夹 - Zip subfolders using ZipOutputStream 如何在包含子文件夹和文件的隔离存储中压缩和解压缩根文件夹 - How to zip and unzip root folder in isolated storage containing subfolders and files 如何在用户选择的根文件夹中创建一个包含一些子文件夹的文件夹? - How to create a folder having some subfolders, in a root folder selected by the user? ZipStorer-MemoryStream中的Zip文本,通过httpResponse传输,无法作为Zip文件打开 - ZipStorer - Zip Text in MemoryStream, Transmit through httpResponse, unable open as Zip File 使用 EWS 查找收件箱文件夹的所有子文件夹 - Find all subfolders of the Inbox folder using EWS 找到最低的子文件夹并将其压缩 - Find the lowest subfolders and zip them 使用.net ZipArchive类检查zip存档是否按名称包含空文件夹 - Check if zip archive contains an empty folder by name using .net ZipArchive class 从其中包含其他.zip文件的文件夹生成zipOutputstream - Generating a zipOutputstream from a folder having other .zip files in it 使用DotNetZip从zip中提取特定文件夹 - Extracting a specific folder from a zip using DotNetZip
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM