Split Zip files in DotNetZip v1.9

Coordinator
Aug 28, 2009 at 9:55 PM
Edited Aug 30, 2009 at 8:00 PM

DotNetZip now lets you create or read "split" zip files.  For this you need v1.9 of the library, currently in preview.

Lots of people have asked for this, and the feature is finally here.  To create a split zip with DotNetZip, set MaxOutputSegmentSize on the ZipFile instance, and then just call Save() as usual.  The zipfile will be saved into multiple discrete files, as many as necessary, each with the given maximum size. 

    using (var zip = new ZipFile())
    {
        zip.AddDirectory(directoryToZip, "files");
        zip.MaxOutputSegmentSize = 128*1024;  // 128k
        zip.Save("Archive.zip");

        Console.WriteLine("number of segments: {0}", 
                          zip.NumberOfSegmentsForMostRecentSave);
    }

The segments are named "Archive.z01, Archive.z02, and so on.  The final file is Archive.zip.  To read a split zip file produced by DotNetZip or WinZip, just do a ZipFile.Read() on the file with the .zip extension.  DotNetZip will automatically load in the .z01 (etc) files as necessary. 

This feature is really handy where there are limits to the sizes of the files you want to create.  For example, when uploading to SkyDrive or when sending a zip file in a series of emails, each of which has a size-limit for the attachment.

As far as I know, every other feature in the library composes nicely with zip splitting.  The exception is self-extracting archive.  You cannot have a "split" SFX, but you can have an AES-encrypted split zip file.  You can have a ZIP64 split archive.  Unicode, etc. 

This is a new feature, and is currently the least tested feature in the library.  So for now this capability is available as an "alpha" release.  As I test it more thoroughly and get comfortable with its reliability, it will graduate into beta and released status.

Please try it out.  http://dotnetzip.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27890