简体   繁体   English

以编程方式合并DotNetZip制造的zip段

[英]Programmatically merging zip segments made by DotNetZip

I have a problem with merging zip segments which I made using DotNetZip library. 我在合并使用DotNetZip库制作的zip段时遇到问题。

I'm zipping big file, which produces files like: abc.zip, abc.z01 and abc.z02. 我正在压缩大文件,该文件会生成类似abc.zip,abc.z01和abc.z02的文件。

using (ZipFile zip = new ZipFile())
{
    zip.AddDirectory(fullDir);
    zip.MaxOutputSegmentSize = 65536;
    zip.Save(packageFullName);

    return zip.NumberOfSegmentsForMostRecentSave;
}

In other service I want to download these files and merge them to only one zip file. 在其他服务中,我想下载这些文件并将它们合并为一个zip文件。 I made this by simply merging theirs byte arrays. 我通过简单地合并他们的字节数组来做到这一点。 Sadly I'm getting error, that archive created by me isn't valid. 不幸的是,我遇到了错误,由我创建的档案无效。

I'm not sure why my approach isn't right. 我不确定为什么我的方法不正确。 I found this stack question: https://superuser.com/questions/15935/how-do-i-reassemble-a-zip-file-that-has-been-emailed-in-multiple-parts - accepted answer also produces invalid archive. 我发现了这个堆栈问题: https : //superuser.com/questions/15935/how-do-i-reassemble-a-zip-file-that-has-been-emailed-in-multiple-parts-接受的答案也会产生无效的存档。

Do anybody knows how can I merge a few DotNetZip files? 有人知道如何合并一些DotNetZip文件吗? I don't really want to extract them in memory and pack once again, but maybe it's the only way. 我并不是很想将它们提取到内存中并再次打包,但这也许是唯一的方法。

dotnetzip can read segment zip files without problem, you can refer it's source code to take a look how it handle the segement files as one zip file, its an internal class you cannot directly use, but it may have a clue tell you how to do it: dotnetzip可以毫无问题地读取段zip文件,您可以参考它的源代码来查看它如何将段文件作为一个zip文件处理,它是您不能直接使用的内部类,但它可能会提示您如何操作它:

http://dotnetzip.codeplex.com/SourceControl/latest#Zip/ZipSegmentedStream.cs http://dotnetzip.codeplex.com/SourceControl/latest#Zip/ZipSegmentedStream.cs

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM