-
-
Notifications
You must be signed in to change notification settings - Fork 3
PKZip.ZipWriter
PKZip.ZipWriter
Protected Class ZipWriter
This class is used to create zip archives. It provides more granular control of the zipping process than the PKZip.WriteZip utility method does.
Create a new instance, and then use the AppendDirectory
and/or AppendEntry
methods to build the archive. When ready, call the Commit
method to generate the archive and write it to a file or memory stream.
The zip file format limits archives to 4GB, both overall and for individual compressed files. File names (including the path), file comments, and file extra data fields are limited to 65535 bytes each.
The number of files in a single archive is technically limited to 65535, however this class does not enforce the limit. Most zip readers (including the ZipReader class) ignore this limit and can handle archives with any number of files.
The zip format does not forbid having two or more entries with identical names, however this class does not support creating such archives.
Dim zip As New PKZip.ZipWriter
Call zip.AppendEntry(GetOpenFolderItem("")) ' add a file to the archive root
Dim dir As FolderItem = SelectFolder
zip.AppendDirectory(dir) ' recursively add contents of directory to archive root
zip.AppendDirectory(dir, dir.Parent) ' recursively add a directory and its contents to archive root
zip.DeleteEntry("path/to/be/deleted.txt") ' delete an entry
zip.Commit(SpecialFolder.Desktop.Child("test.zip"))
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2014-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.