Skip to content
Andrew Lambert edited this page May 18, 2021 · 8 revisions

PKZip.WriteZip

Method Signatures

 Protected Function WriteZip(ToArchive() As FolderItem, OutputFile As FolderItem, RelativeRoot As FolderItem, Overwrite As Boolean = False, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION) As Boolean
 Protected Function WriteZip(ToArchive As FolderItem, OutputFile As FolderItem, Overwrite As Boolean = False, CompressionLevel As Integer = zlib.Z_DEFAULT_COMPRESSION) As Boolean

Parameters

WriteZip(FolderItem(), FolderItem, FolderItem, Boolean, Integer)

Name Type Comment
ToArchive FolderItem array A list of files and folders to be archived.
OutputFile FolderItem The archive file.
RelativeRoot FolderItem Optional. The root of the directory structure to recreate in the archive.
Overwrite Boolean Optional. If True then the OutputFile is overwritten if it exists.
CompressionLevel Integer Optional. A number between 1 and 9 controlling how aggressive the compression should be (or 0 for no compression).

WriteZip(FolderItem, FolderItem, Boolean, Integer)

Name Type Comment
ToArchive FolderItem The directory to be recursively archived.
OutputFile FolderItem The archive file.
Overwrite Boolean Optional. If True then the OutputFile is overwritten if it exists.
CompressionLevel Integer Optional. A number between 1 and 9 controlling how aggressive the compression should be (or 0 for no compression).

Return value

Returns True if the operation was successful.

Remarks

Creates the OutputFile as a Zip archive containing the files specified by ToArchive.

Example

This example creates a new zip archive by recursively compressing a directory structure:

  Dim zipfile As FolderItem = GetSaveFolderItem("", "output.zip") ' the zip file
  Dim target As FolderItem = SelectFolder() '  the target folder
  If Not PKZip.WriteZip(target, zipfile) Then MsgBox("Zip error!")

See also

Entry-level points of interest denoted by "☜"



Clone this wiki locally