我尝试更改现有的拉链工具。压缩工具目前使用的是SharpZipLib。我必须转换它,以便它使用SevenZipSharp。当使用SharpZipLib压缩时,我可以更改压缩包的根目录,当使用SevenZipSharp时,我希望保留这个根目录。
例如,如果我有绝对结构
C:/
├──root/
└── folders/
└── files/
├── text1.txt
├── text2.txt
├── text3.txt
├── text4.txt
└── subfiles/
└── text5.txt然后,我的SevenSharpZip将创建一个包含以下内容的压缩包:
text1.txt
text2.txt
text3.txt
text4.txt
└── subfiles/
└── text5.txt SharpZipLib将创建以下内容
root/
└── folders/
└── files/
├── text1.txt
├── text2.txt
├── text3.txt
├── text4.txt
└── subfiles/
└── text5.txt有没有可能为SevenZipSharp设置一个根目录,使我的两个zip具有相同的内部结构?我还没有找到相应的设置来改变它。IncludeEmptyDirectory,PreserveDirectoryRoot和DirectoryStructure没有给我想要的结果。
发布于 2020-03-20 16:05:25
我找到了答案。要设置根文件夹,我必须使用以下方法
public void CompressFiles(string archiveName, int commonRootLength, params string[] fileFullNames)这就是commonRootLength了。这是我们共同的根的起点。对于我上面的例子,这意味着公共根在第一个"/“之后开始,这意味着commonRootLenght参数需要是3。
https://stackoverflow.com/questions/60757355
复制相似问题