我需要使用.Net创建跨区(多卷)zip文件,但我无法找到一个可以让我这样做的库.
跨区zip是一个zip压缩文件,分为多个文件,通常具有.z00,.z01等扩展名.
该库必须是开源的或免费的,因为我将把它用于开源项目.
(这是这个问题的重复,但那里没有答案,我也不打算使用ASP特定的)
Nic*_*rey 25
DotNetZip示例:
int segmentsCreated ;
using (ZipFile zip = new ZipFile())
{
zip.UseUnicode= true; // utf-8
zip.AddDirectory(@"MyDocuments\ProjectX");
zip.Comment = "This zip was created at " + System.DateTime.Now.ToString("G") ;
zip.MaxOutputSegmentSize = 100*1024 ; // 100k segments
zip.Save("MyFiles.zip");
segmentsCreated = zip.NumberOfSegmentsForMostRecentSave ;
}
Run Code Online (Sandbox Code Playgroud)
如果segmentsCreated回到5,那么你有以下文件,每个文件的大小不超过100kb.
编辑注: DotNetZip曾经住在Codeplex.Codeplex已关闭.旧档案仍然[可在Codeplex] [1]获得.看起来代码已迁移到Github: