[英]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.