Zip Code Example: Real time addition of files to an archive
Note: This is only applicable to Java and .NET editions at this time.
To enable this functionality set the CloseArchiveAfterCompress setting to False. This setting determines whether the archive is closed after calling Compress. When set to False the archive remains open and additional files can be added at any time. This allows files to be added to the archive incrementally as they become available. For instance:
zip.Config("CloseArchiveAfterCompress=false");
//Add one file
zip.Files.Add(new ZIPFile("..\\..\\files\\test.txt"));
zip.Compress();
//Add another file
zip.Files.Clear();
zip.Files.Add(new ZIPFile("..\\..\\files\\test2.txt"));
zip.Compress();
//Ready to finish creating the archive
zip.Config("CloseArchiveAfterCompress=true");
zip.Files.Clear();
zip.Compress(); //Must be called to finish archive creation
As illustrated in the code above this setting must be set to True after all files are added to the archive and Compress must be called a final time to complete the archive creation.
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.