Zip CkPython Reference Documentation
CkZip
Current Version: 11.4.0
The Chilkat.Zip class provides methods and properties for creating, reading, modifying, and extracting ZIP archives. It supports adding files from the local filesystem, adding data directly from memory, extracting selected or matching entries, working with encrypted ZIP files, and writing ZIP output to disk or memory.
ZIP archives can be built incrementally by adding file references, strings, binary data, empty entries, or entries from another ZIP archive, and then finalized by calling one of the Write* methods. The class also supports ZIP64 for large archives, ZIPX compression, legacy Zip 2.0 password protection, WinZip-compatible AES encryption, and Windows self-extracting EXE creation.
For a higher-level introduction and overview, see: Chilkat Zip Class Overview
Object Creation
obj = chilkat.CkZip()
Properties
AbortCurrent
boolVal = zip.get_AbortCurrent();
zip.put_AbortCurrent(boolVal);
Stops the currently executing operation when set to .True
- Used to cancel long-running operations such as compression or extraction.
- Can be triggered from another thread.
- Automatically resets to
after the operation stops.False
AppendFromDir
# ckStr is a CkString
zip.get_AppendFromDir(ckStr);
strVal = zip.appendFromDir();
zip.put_AppendFromDir(strVal);
Specifies a base directory when adding files to the ZIP.
- This portion of the path is not included in stored ZIP entry paths.
- Useful for controlling relative paths inside the archive.
For example, to add all files under c:/abc/123/myAppDir, this property could be set to c:/abc/123, and myAppDir/* would be passed to AppendFiles.
The path stored in the ZIP would begin with myAppDir/.
AutoRun
# ckStr is a CkString
zip.get_AutoRun(ckStr);
strVal = zip.autoRun();
zip.put_AutoRun(strVal);
(Windows only, for creating self-extracting EXE's)
Specifies the name of an executable inside a self-extracting EXE that runs automatically after extraction.
topAutoRunParams
# ckStr is a CkString
zip.get_AutoRunParams(ckStr);
strVal = zip.autoRunParams();
zip.put_AutoRunParams(strVal);
(Windows only, for creating self-extracting EXE's)
Command-line arguments passed to the AutoRun executable.
AutoTemp
boolVal = zip.get_AutoTemp();
zip.put_AutoTemp(boolVal);
(Windows only, for creating self-extracting EXE's)
If , the EXE being created will automatically select and create a temporary directory for unzipping.True
This property is often used together with AutoRun to create a self-extracting EXE that automatically unzips to a temporary directory and runs a setup program, such as setup.exe, without user interaction.
Note: To create a self-extracting EXE with no user interaction, set the following properties:
ExeSilentProgress =False
ExeNoInterface =True
ExeFinishNotifier =False
The default value is .False
CaseSensitive
boolVal = zip.get_CaseSensitive();
zip.put_CaseSensitive(boolVal);
Controls whether filename matching is case-sensitive.
- Affects methods such as
EntryMatchingandUnzipMatching. - Default:
False
ClearArchiveAttribute
boolVal = zip.get_ClearArchiveAttribute();
zip.put_ClearArchiveAttribute(boolVal);
(Windows only)
If , clears the Windows archive attribute after files are successfully added to the ZIP.True
The archive attribute indicates that a file has changed since the last backup.
The default value is .False
ClearReadOnlyAttr
boolVal = zip.get_ClearReadOnlyAttr();
zip.put_ClearReadOnlyAttr(boolVal);
If , removes the read-only attribute from extracted files.True
If , the read-only attribute remains unchanged.False
The default value is .False
Comment
# ckStr is a CkString
zip.get_Comment(ckStr);
strVal = zip.comment();
zip.put_Comment(strVal);
DebugLogFilePath
# ckStr is a CkString
zip.get_DebugLogFilePath(ckStr);
strVal = zip.debugLogFilePath();
zip.put_DebugLogFilePath(strVal);
If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.
Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.
Possible causes of hangs include:
- A timeout property set to 0, indicating an infinite timeout.
- A hang occurring within an event callback in the application code.
- An internal bug in the Chilkat code causing the hang.
DecryptPassword
# ckStr is a CkString
zip.get_DecryptPassword(ckStr);
strVal = zip.decryptPassword();
zip.put_DecryptPassword(strVal);
Password used to extract encrypted ZIP archives.
- Required to unzip encrypted entries.
- Encrypted ZIP files may still be opened without a password, but their contents cannot be extracted until the correct password is provided.
The default value is the empty string.
topDiscardPaths
boolVal = zip.get_DiscardPaths();
zip.put_DiscardPaths(boolVal);
If , removes all directory path information when adding files.True
Only filenames are stored in the ZIP.
The default value is .False
Encryption
intVal = zip.get_Encryption();
zip.put_Encryption(intVal);
Specifies encryption mode:
0→ No encryption4→ WinZip-compatible AES encryption
Important: Encryption and PasswordProtect are mutually exclusive.
If PasswordProtect = , then TrueEncryption should be 0.
The default value is 0.
EncryptKeyLength
intVal = zip.get_EncryptKeyLength();
zip.put_EncryptKeyLength(intVal);
Specifies the AES encryption key length.
- Valid values:
128,192, or256
The default value is 128.
EncryptPassword
# ckStr is a CkString
zip.get_EncryptPassword(ckStr);
strVal = zip.encryptPassword();
zip.put_EncryptPassword(strVal);
ExeDefaultDir
# ckStr is a CkString
zip.get_ExeDefaultDir(ckStr);
strVal = zip.exeDefaultDir();
zip.put_ExeDefaultDir(strVal);
(Windows only, for creating self-extracting EXE's)
Default extraction directory shown in the self-extracting EXE user interface.
The default value is the empty string.
topExeFinishNotifier
boolVal = zip.get_ExeFinishNotifier();
zip.put_ExeFinishNotifier(boolVal);
(Windows only, for creating self-extracting EXE's)
If , displays a completion dialog after extraction finishes.True
The default value is .False
ExeIconFile
# ckStr is a CkString
zip.get_ExeIconFile(ckStr);
strVal = zip.exeIconFile();
zip.put_ExeIconFile(strVal);
(Windows only, for creating self-extracting EXE's)
Path to an .ico file used as the EXE icon.
This feature is only available when the application creating the EXE is 32-bit.
The default value is the empty string.
topExeNoInterface
boolVal = zip.get_ExeNoInterface();
zip.put_ExeNoInterface(boolVal);
(Windows only, for creating self-extracting EXE's)
If , runs the self-extracting EXE without displaying the main user interface.True
The default value is .False
ExeSilentProgress
boolVal = zip.get_ExeSilentProgress();
zip.put_ExeSilentProgress(boolVal);
(Windows only, for creating self-extracting EXE's)
Controls whether a progress dialog is shown during extraction.
If ExeNoInterface = , the progress bar appears within the main dialog and this property has no effect.False
The default value is .False
ExeTitle
# ckStr is a CkString
zip.get_ExeTitle(ckStr);
strVal = zip.exeTitle();
zip.put_ExeTitle(strVal);
(Windows only, for creating self-extracting EXE's)
Title displayed in the self-extracting EXE dialog.
The default value is the empty string.
topExeUnzipCaption
# ckStr is a CkString
zip.get_ExeUnzipCaption(ckStr);
strVal = zip.exeUnzipCaption();
zip.put_ExeUnzipCaption(strVal);
(Windows only, for creating self-extracting EXE's)
Caption text displayed in the self-extracting EXE dialog.
The default value is the empty string.
topExeUnzipDir
# ckStr is a CkString
zip.get_ExeUnzipDir(ckStr);
strVal = zip.exeUnzipDir();
zip.put_ExeUnzipDir(strVal);
(Windows only, for creating self-extracting EXE's)
Specifies a predefined extraction directory.
- Supports environment variables such as
%TEMP%. - UNC paths are not supported.
The default value is the empty string.
topExeWaitForSetup
boolVal = zip.get_ExeWaitForSetup();
zip.put_ExeWaitForSetup(boolVal);
If , waits for the AutoRun executable to finish before exiting.True
If , the self-extracting EXE may exit before the AutoRun executable completes.False
The default value is .True
ExeXmlConfig
# ckStr is a CkString
zip.get_ExeXmlConfig(ckStr);
strVal = zip.exeXmlConfig();
zip.put_ExeXmlConfig(strVal);
Allows for an XML config document to be used to specify all possible options for self-extracting EXEs. This property is a string containing the XML config document.
The XML should have this format:
MainUnzipLabel must also be set for this to take effect.</MainUnzipBtn>
MainUnzipLabel must also be set for this to take effect.</MainCloseBtn>
MainUnzipLabel must also be set for this to take effect.</MainBrowseBtn>
AutoTemp property)</AutoTemp>
SetupExe is run.)</Cleanup>
ExeFinishNotifier property)</ShowFin>
ExeNoInterface property)</ShowMain>
ExeSilentProgress property)</ShowProgress>
ExeWaitForSetup property)</WaitForSetup>
AutoRun property)</SetupExe>
ExeUnzipDir property. UNC paths, such as \\servername\path, are not supported.)</UnzipDir>
ExeDefaultDir property)</DefaultDir>
ExeIconFile property)</IconFile>
ExeTitle property.</MainTitle>
ExeUnzipCaption property.</MainCaption>
A self-extracting EXE can be run from the command line with the
-log {logFilePath} option to create a log with information for debugging.
FileCount
intVal = zip.get_FileCount();
Number of files in the ZIP, excluding directory entries.
topFileName
# ckStr is a CkString
zip.get_FileName(ckStr);
strVal = zip.fileName();
zip.put_FileName(strVal);
HasZipFormatErrors
boolVal = zip.get_HasZipFormatErrors();
Indicates whether minor ZIP format problems were detected when opening the ZIP archive.
topIgnoreAccessDenied
boolVal = zip.get_IgnoreAccessDenied();
zip.put_IgnoreAccessDenied(boolVal);
If , files that cannot be read, written, or created due to filesystem permission errors are skipped.True
If , any access-denied error causes the ZIP operation to fail.False
The default value is .True
LastErrorHtml
# ckStr is a CkString
zip.get_LastErrorHtml(ckStr);
strVal = zip.lastErrorHtml();
Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastErrorText
# ckStr is a CkString
zip.get_LastErrorText(ckStr);
strVal = zip.lastErrorText();
Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
LastErrorXml
# ckStr is a CkString
zip.get_LastErrorXml(ckStr);
strVal = zip.lastErrorXml();
Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.
topLastMethodSuccess
boolVal = zip.get_LastMethodSuccess();
zip.put_LastMethodSuccess(boolVal);
Indicates the success or failure of the most recent method call: True means success, False means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.
MaxDate
# ckStr is a CkString
zip.get_MaxDate(ckStr);
strVal = zip.maxDate();
zip.put_MaxDate(strVal);
Maximum last-modified timestamp for files processed during add or extract operations.
Files having modification timestamps later than this value are skipped.
Supports ISO 8601 date/time formats, including:
YYYY-MM-DD
Example:2024-07-31YYYY-MM-DDTHH:MM:SS±HH:MM
Example:2024-07-31T12:34:56+02:00YYYY-MM-DDTHH:MM:SSZ
Example:2024-07-31T12:34:56Z
The default value is the empty string, meaning no maximum date restriction.
MaxUncompressSize
intVal = zip.get_MaxUncompressSize();
zip.put_MaxUncompressSize(intVal);
Prevents extraction of files larger than the specified uncompressed size.
A value of 0 means no size limit.
The default value is 0.
MinDate
# ckStr is a CkString
zip.get_MinDate(ckStr);
strVal = zip.minDate();
zip.put_MinDate(strVal);
Minimum last-modified timestamp for files processed during add or extract operations.
Supports ISO 8601 date/time formats, including:
YYYY-MM-DD
Example:2024-07-31YYYY-MM-DDTHH:MM:SS±HH:MM
Example:2024-07-31T12:34:56+02:00YYYY-MM-DDTHH:MM:SSZ
Example:2024-07-31T12:34:56Z
The default value is the empty string, meaning no minimum date restriction.
NumEntries
intVal = zip.get_NumEntries();
Total number of entries in the ZIP, including both files and directories.
OemCodePage
intVal = zip.get_OemCodePage();
zip.put_OemCodePage(intVal);
Specifies the OEM code page used for ZIP filename encoding.
Defaults to the OEM code page of the current computer.
topOverwriteExisting
boolVal = zip.get_OverwriteExisting();
zip.put_OverwriteExisting(boolVal);
PasswordProtect
boolVal = zip.get_PasswordProtect();
zip.put_PasswordProtect(boolVal);
Indicates whether the ZIP uses legacy Zip 2.0 password protection.
This property is set automatically when a ZIP archive is opened by any of the Open* methods, such as OpenZip, OpenFromMemory, OpenBd, and related methods.
Important: PasswordProtect and Encryption are mutually exclusive.
If PasswordProtect = , then TrueEncryption should be 0.
The default value is .False
PathPrefix
# ckStr is a CkString
zip.get_PathPrefix(ckStr);
strVal = zip.pathPrefix();
zip.put_PathPrefix(strVal);
Gets or sets a path prefix that is prepended to ZIP entry paths for files appended from the local filesystem.
This is useful when you want all extracted files to appear under a specific subdirectory.
This property affects only the following methods:
-
AppendFiles -
AppendFilesEx -
AddFile -
AppendOneFileOrDir
The PathPrefix value is prepended to the stored ZIP
path for each appended filesystem file.
For example, set PathPrefix to subdir/ so that files are stored in the ZIP with subdir/ prepended to their paths. When extracted, the files will be placed under the subdir directory.
This property does not affect entries added entirely from memory, such as entries added using:
-
AddString -
AddData -
AddBd -
AddSb
For in-memory entries, the ZIP entry path is determined solely by the filename/path argument passed to the method.
The default value is the empty string.
PwdProtCharset
# ckStr is a CkString
zip.get_PwdProtCharset(ckStr);
strVal = zip.pwdProtCharset();
zip.put_PwdProtCharset(strVal);
Specifies the character encoding used to convert the decrypt password into its binary byte representation for legacy password-protected ZIP archives that use Zip 2.0 encryption.
The default value is ansi.
Other possible values include:
cp850cp437- Any supported Windows or OEM code page listed at the link below.
This property applies only to older Zip 2.0 password protection and is not used for AES-encrypted ZIP archives.
topTempDir
# ckStr is a CkString
zip.get_TempDir(ckStr);
strVal = zip.tempDir();
zip.put_TempDir(strVal);
Directory used for temporary files during ZIP operations.
When overwriting an existing ZIP file, a temporary file is used to avoid corrupting the original ZIP if an error occurs.
The default value depends on the runtime environment.
topUncommonOptions
# ckStr is a CkString
zip.get_UncommonOptions(ckStr);
strVal = zip.uncommonOptions();
zip.put_UncommonOptions(strVal);
Advanced options for uncommon scenarios.
ForceZip64→ Forces ZIP64 format even when not required.
The default value is the empty string.
topUtf8
boolVal = zip.get_Utf8();
zip.put_Utf8(boolVal);
When set to True, all string arguments and return values are interpreted as UTF-8 strings. When set to False, they are interpreted as ANSI strings.
In Chilkat v11.0.0 and later, the default value is True. Before v11.0.0, it was False.
VerboseLogging
boolVal = zip.get_VerboseLogging();
zip.put_VerboseLogging(boolVal);
If set to True, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is False. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.
Version
Zipx
boolVal = zip.get_Zipx();
zip.put_Zipx(boolVal);
If , creates ZIPX archives using the most appropriate compression method for each file.True
The default value is .False
ZipxDefaultAlg
# ckStr is a CkString
zip.get_ZipxDefaultAlg(ckStr);
strVal = zip.zipxDefaultAlg();
zip.put_ZipxDefaultAlg(strVal);
Default compression algorithm used when creating ZIPX archives.
- Possible values include:
deflateppmdlzmabzip2deflate64
The default value is deflate.
Methods
AddBd
Adds the contents of a BinData object as a new entry in the ZIP archive.
pathInZipspecifies the filename and optional directory path stored within the ZIP.- The bytes contained in
bdbecome the contents of the ZIP entry. - The entry is added to the in-memory ZIP object and is not written to disk until
WriteZip,WriteZipAndClose,WriteBd, orWriteToMemoryis called.
Returns True for success, False for failure.
AddEmpty
# pathInZip is a string
status = zip.AddEmpty(isDir, pathInZip);
Adds an empty file or directory entry to the ZIP archive.
- If
isDir =, an empty directory entry is created.True - If
isDir =, an empty file entry is created.False pathInZipspecifies the path stored in the ZIP archive.
This method is useful when directory structure entries must exist even if no files are present.
Returns True for success, False for failure.
AddEncoded
# encoding is a string
# data is a string
status = zip.AddEncoded(pathInZip, encoding, data);
Adds encoded binary data as a ZIP entry.
encodingspecifies howdatais encoded.- Common encodings include
base64andhex. - The decoded binary bytes become the contents of the ZIP entry.
This method is useful when binary data already exists in textual encoded form.
Returns True for success, False for failure.
AddFile
# saveExtraPath is a boolean
status = zip.AddFile(localPath, saveExtraPath);
Adds a file or directory from the local filesystem to the ZIP archive.
- If
localPathis an absolute path andsaveExtraPath =, the stored ZIP path includes the relative directory structure.True - If
saveExtraPath =, only the filename is stored.False - If
localPathis already relative, the relative path is stored as-is regardless ofsaveExtraPath.
This method adds a reference to the file or directory in the local filesystem. The file data is not immediately read or compressed.
The actual file contents are consumed only when a Write* method is called, such as:
WriteZipWriteZipAndCloseWriteBdWriteToMemory
This allows files and data entries to be accumulated in the in-memory ZIP object prior to writing the final ZIP archive.
Returns True for success, False for failure.
AddNoCompressExtension
zip.AddNoCompressExtension(fileExtension);
Adds a file extension to the internal "no-compression" list.
Files having these extensions are stored without compression because they are already compressed or because compression would provide little benefit.
For example:
.zip.jpg.png.gz
The extension may be specified with or without the leading dot.
Additional extensions remain active for the lifetime of the Zip object unless removed with RemoveNoCompressExtension.
AddSb
# sb is a CkStringBuilder
# charset is a string
status = zip.AddSb(pathInZip, sb, charset);
Adds the contents of a StringBuilder object as a text entry in the ZIP archive.
- The text is converted to bytes using the specified
charset. pathInZipspecifies the filename stored in the ZIP.
Returns True for success, False for failure.
AddString
# content is a string
# charset is a string
status = zip.AddString(pathInZip, content, charset);
Adds a string as a text file entry in the ZIP archive.
- The string is converted to bytes using the specified
charset. pathInZipspecifies the path stored within the ZIP archive.
This method is useful for dynamically generating text files directly in memory.
Returns True for success, False for failure.
AppendFiles
# recurse is a boolean
status = zip.AppendFiles(filePattern, recurse);
Adds one or more files matching a wildcard pattern.
- The wildcard character
*matches zero or more characters. - If
recurse =, subdirectories are processed recursively.True - If
recurse =, only the current directory is searched.False
For example:
AppendFiles("c:/temp/*.txt", False)
This method only updates the in-memory ZIP object. The ZIP file itself is not written until a Write* method is called.
Returns True for success, False for failure.
AppendFilesAsync (1)
# filePattern is a string
# recurse is a boolean
ret_task = zip.AppendFilesAsync(filePattern, recurse);
Creates an asynchronous task to call the AppendFiles method with the arguments provided.
Returns None on failure
AppendFilesEx
# recurse is a boolean
# saveExtraPath is a boolean
# archiveOnly is a boolean
# includeHidden is a boolean
# includeSystem is a boolean
status = zip.AppendFilesEx(filePattern, recurse, saveExtraPath, archiveOnly, includeHidden, includeSystem);
Advanced version of AppendFiles with additional filtering and path options.
saveExtraPathcontrols whether the extra leading path information from thefilePatternis preserved in the ZIP.archiveOnlyapplies only on Windows and limits processing to files having the archive attribute set.includeHiddencontrols whether hidden files are included.includeSystemcontrols whether files with the System attribute are included.
This method adds references to files in the in-memory ZIP object. No ZIP file is written until a Write* method is called.
Returns True for success, False for failure.
AppendFilesExAsync (1)
# filePattern is a string
# recurse is a boolean
# saveExtraPath is a boolean
# archiveOnly is a boolean
# includeHidden is a boolean
# includeSystem is a boolean
ret_task = zip.AppendFilesExAsync(filePattern, recurse, saveExtraPath, archiveOnly, includeHidden, includeSystem);
Creates an asynchronous task to call the AppendFilesEx method with the arguments provided.
Returns None on failure
AppendZip
status = zip.AppendZip(zipPath);
Note: This method is currently not working and will be fixed in v11.5.0
Adds all entries from another existing ZIP archive into the current ZIP object.
The zipPath argument specifies the path of a ZIP file located in the local filesystem.
All entries from the specified ZIP archive are appended to the current in-memory ZIP object.
The ZIP archive itself is not rewritten until a Write* method is called.
This method is useful for merging the contents of multiple ZIP archives into a single ZIP.
Returns True for success, False for failure.
CloseZip
Closes the currently open ZIP archive and clears all entries from the Zip object.
This method has the same effect as calling NewZip without specifying a filename.
DeleteEntry
Removes a ZIP entry from the current ZIP object.
The ZIP file itself is not rewritten until a Write* method is called.
Returns True for success, False for failure.
EntryAt
Retrieves the ZIP entry at the specified zero-based index.
- The first entry is at index
0. - The matching entry is returned in the supplied
ZipEntryobject.
Returns True for success, False for failure.
EntryById
Finds a ZIP entry by its unique EntryID.
The matching entry is returned in the supplied ZipEntry object.
Returns True for success, False for failure.
EntryMatching
Finds the first ZIP entry whose stored path matches a wildcard pattern.
- The wildcard character
*matches zero or more characters. - The comparison is performed against the full stored ZIP path.
Returns True for success, False for failure.
EntryOf
Finds a ZIP entry whose stored path exactly matches pathInZip.
The matching entry is returned in the supplied ZipEntry object.
Returns True for success, False for failure.
ExcludeDir
zip.ExcludeDir(dirName);
Adds a directory name to the exclusion list used by recursive append operations.
- All directories having the specified name are skipped.
- The comparison is case-insensitive.
- Call multiple times to exclude multiple directory names.
This affects methods such as AppendFiles and AppendFilesEx.
ExtractExe
# dirPath is a string
status = zip.ExtractExe(exePath, dirPath);
Extracts files from a Chilkat-created self-extracting EXE.
- Files are extracted into
dirPath. - Subdirectories are automatically created as needed.
- If the EXE is encrypted,
DecryptPasswordmust be set before extraction.
Returns True for success, False for failure.
topExtractExeAsync (1)
# exePath is a string
# dirPath is a string
ret_task = zip.ExtractExeAsync(exePath, dirPath);
Creates an asynchronous task to call the ExtractExe method with the arguments provided.
Returns None on failure
GetDirectoryAsXML
status = zip.GetDirectoryAsXML(outStr);
retStr = zip.getDirectoryAsXML();
Returns the ZIP directory structure as an XML document.
The returned XML contains information about the entries currently contained within the ZIP archive, including files and directories.
This method is useful for inspecting ZIP contents without extracting files.
Returns the XML document as a string.
Returns True for success, False for failure.
GetExeConfigParam
# outStr is a CkString (output)
status = zip.GetExeConfigParam(name, outStr);
retStr = zip.getExeConfigParam(name);
(Windows only, for creating self-extracting EXE's)
Returns the value of a configuration parameter embedded within a self-extracting EXE.
The name argument should be one of the XML tag names described in the ExeXmlConfig property documentation.
For example:
MainTitleMainCaptionSetupExe
Returns the parameter value as a string.
Returns True for success, False for failure.
topGetMaxUncompressedSize
status = zip.GetMaxUncompressedSize(outStr);
retStr = zip.getMaxUncompressedSize();
Returns the largest uncompressed file size contained within the ZIP archive.
The size is returned as a string rather than an integer because the value may exceed the range of a 32-bit integer.
This method is useful when:
- Checking for extremely large files before extraction
- Estimating required disk space
- Detecting unusually large compressed entries
Returns the size as a decimal string.
Returns True for success, False for failure.
topIsNoCompressExtension
retBool = zip.IsNoCompressExtension(fileExtension);
Checks whether a file extension is contained in the internal "no-compression" extension list.
Files having extensions in this list are stored without compression because they are typically already compressed.
The extension may be specified with or without the leading dot.
For example, both of the following are valid:
.jpgjpg
Returns if the extension exists in the list, otherwise returns True.False
IsPasswordProtected
retBool = zip.IsPasswordProtected(zipPath);
Checks whether a ZIP archive uses legacy Zip 2.0 password protection.
The zipPath argument specifies the path of a ZIP file in the local filesystem.
This method checks only for traditional Zip 2.0 password protection.
Returns if the ZIP archive is password protected, otherwise returns True.False
LoadTaskCaller
NewZip
retBool = zip.NewZip(zipPath);
Initializes a new empty ZIP archive.
- If another ZIP archive is currently open, it is closed.
- All existing in-memory ZIP entries are discarded.
- The
FileNameproperty is set tozipPath.
No ZIP file is actually created until a Write* method is called.
This method resets the Zip object to a clean empty state.
OpenBd
Opens a ZIP archive contained entirely within a BinData object.
This method allows ZIP archives to be processed entirely in memory without requiring a filesystem file.
When a ZIP archive is opened:
PasswordProtectis automatically set if legacy Zip 2.0 encryption is detected.Encryptionis automatically set if strong encryption is detected.- A value of
4forEncryptionindicates WinZip-compatible AES encryption.
Returns True for success, False for failure.
OpenEmbedded
# resourceName is a string
status = zip.OpenEmbedded(exeFilename, resourceName);
(Windows only)
Opens a ZIP archive embedded as a resource within a Windows executable.
exeFilenamespecifies the EXE file path.resourceNamespecifies the embedded resource name containing the ZIP data.
This method is useful when ZIP archives are packaged within Windows applications.
Returns True for success, False for failure.
topOpenZip
status = zip.OpenZip(zipPath);
Opens a ZIP archive from the local filesystem.
The zipPath argument specifies the path of the ZIP file to open.
Encrypted ZIP archives may be opened without providing a password, but encrypted entries cannot be extracted until the correct password is provided using DecryptPassword.
When the ZIP archive is opened:
PasswordProtectis automatically set if legacy Zip 2.0 encryption is detected.Encryptionis automatically set if strong encryption is detected.Encryption = 4indicates WinZip-compatible AES encryption.
Returns True for success, False for failure.
OpenZipAsync (1)
Creates an asynchronous task to call the OpenZip method with the arguments provided.
Returns None on failure
QuickAppend
status = zip.QuickAppend(zipPath);
Efficiently appends additional entries to an existing ZIP archive.
The zipPath argument specifies the path of an existing ZIP archive in the local filesystem.
This method avoids rewriting existing entries.
- Existing ZIP entries remain unchanged.
- New entries are appended to the end of the ZIP archive.
- The ZIP central directory is updated accordingly.
This method is typically faster than rebuilding the entire ZIP archive.
Returns True for success, False for failure.
QuickAppendAsync (1)
Creates an asynchronous task to call the QuickAppend method with the arguments provided.
Returns None on failure
RemoveNoCompressExtension
zip.RemoveNoCompressExtension(fileExtension);
Removes a file extension from the internal "no-compression" extension list.
After removal, files having this extension may be compressed normally.
The extension may be specified with or without the leading dot.
topSetCompressionLevel
zip.SetCompressionLevel(level);
Sets the compression level for all file and data entries currently contained within the ZIP object.
0→ No compression9→ Maximum compression
The default compression level is 6.
Important: This method should be called after files or data entries have already been added to the ZIP object.
The compression level cannot be changed for mapped entries originating from an already-open ZIP archive.
topSetExclusions
Specifies a collection of wildcard exclusion patterns used when adding files to the ZIP archive.
Each pattern may use the wildcard character * to match zero or more characters.
Files matching any exclusion pattern are skipped.
SetExeConfigParam
# paramValue is a string
zip.SetExeConfigParam(paramName, paramValue);
(Windows only, for creating self-extracting EXE's)
Sets a configuration parameter embedded within a self-extracting EXE created by WriteExe or WriteExe2.
The paramName should be one of the XML configuration tag names described in the ExeXmlConfig property documentation.
For example:
SetExeConfigParam("MainUnzipBtn","Extract")
This changes the text displayed on the self-extractor's main unzip button.
topUnzip
retInt = zip.Unzip(dirPath);
Extracts all files and directories from the ZIP archive.
dirPathspecifies the destination directory.- Subdirectories are automatically created as needed.
Returns the number of files extracted.
Returns -1 if a failure occurs.
UnzipAsync (1)
Creates an asynchronous task to call the Unzip method with the arguments provided.
Returns None on failure
UnzipInto
retInt = zip.UnzipInto(dirPath);
Extracts all files into a single directory.
All directory path information stored within the ZIP archive is ignored.
If multiple files have the same filename, later extracted files overwrite earlier ones.
Returns the number of files extracted, or -1 on failure.
UnzipIntoAsync (1)
Creates an asynchronous task to call the UnzipInto method with the arguments provided.
Returns None on failure
UnzipMatching
# pattern is a string
# verbose is a boolean
retInt = zip.UnzipMatching(dirPath, pattern, verbose);
Extracts only entries whose stored paths match a wildcard pattern.
- The wildcard character
*matches zero or more characters. - If no wildcard is used, an exact filename match is required.
Subdirectories are automatically created as needed.
Returns the number of files extracted, or -1 on failure.
UnzipMatchingAsync (1)
# dirPath is a string
# pattern is a string
# verbose is a boolean
ret_task = zip.UnzipMatchingAsync(dirPath, pattern, verbose);
Creates an asynchronous task to call the UnzipMatching method with the arguments provided.
Returns None on failure
UnzipMatchingInto
# pattern is a string
# verbose is a boolean
retInt = zip.UnzipMatchingInto(dirPath, pattern, verbose);
Extracts matching entries into a single directory while ignoring all stored ZIP path information.
Matching behavior is identical to UnzipMatching.
If duplicate filenames occur, later extracted files overwrite earlier ones.
Returns the number of files extracted, or -1 on failure.
UnzipMatchingIntoAsync (1)
# dirPath is a string
# pattern is a string
# verbose is a boolean
ret_task = zip.UnzipMatchingIntoAsync(dirPath, pattern, verbose);
Creates an asynchronous task to call the UnzipMatchingInto method with the arguments provided.
Returns None on failure
UnzipNewer
retInt = zip.UnzipNewer(dirPath);
Extracts only files that:
- Do not already exist
- Or have older modification timestamps than the ZIP entry
Subdirectories are automatically created as needed.
Returns the number of files extracted, or -1 on failure.
UnzipNewerAsync (1)
Creates an asynchronous task to call the UnzipNewer method with the arguments provided.
Returns None on failure
VerifyPassword
Verifies that the current DecryptPassword value is correct for the currently opened ZIP archive.
This method allows password validation before attempting extraction.
Returns if the password is valid, otherwise returns True.False
WriteBd
Writes the ZIP archive to a BinData object instead of a filesystem file.
The generated ZIP archive exists entirely in memory.
The ZIP data written by this method may later be opened using OpenBd.
Returns True for success, False for failure.
WriteBdAsync (1)
Creates an asynchronous task to call the WriteBd method with the arguments provided.
Returns None on failure
WriteExe
status = zip.WriteExe(exeFilename);
(Windows only, for creating self-extracting EXE's)
Creates a Windows self-extracting executable (EXE).
The generated EXE contains both the extraction logic and the ZIP archive data.
There are no limitations on:
- Total ZIP size
- Individual file size
- Number of files
The generated EXE supports the following command-line arguments:
-log logFileName-unzipDir unzipDirectoryPath-pwd password-ap autoRunParams
Returns True for success, False for failure.
WriteExeAsync (1)
Creates an asynchronous task to call the WriteExe method with the arguments provided.
Returns None on failure
WriteZip
Saves the Zip to a file and implictly re-opens it so further operations can continue. Use WriteZipAndClose to write and close the Zip. There is no limitation on the size of files that may be contained within a .zip, the total number of files in a .zip, or the total size of a .zip. If necessary, WriteZip will use the ZIP64 file format extensions when 4GB or file count limitations of the old zip file format are exceeded.
Returns True for success, False for failure.
WriteZipAsync (1)
Creates an asynchronous task to call the WriteZip method with the arguments provided.
Returns None on failure
WriteZipAndClose
Saves the Zip to a file and closes it. On return, the Zip object will be in the state as if NewZip had been called. There is no limitation on the size of files that may be contained within a .zip, the total number of files in a .zip, or the total size of a .zip. If necessary, WriteZip will use the ZIP64 file format extensions when 4GB or file count limitations of the old zip file format are exceeded.
Returns True for success, False for failure.
WriteZipAndCloseAsync (1)
Creates an asynchronous task to call the WriteZipAndClose method with the arguments provided.
Returns None on failure
Deprecated
AppendBd
# pathInZip is a string
# byteData is a CkBinData
ret_zipEntry = zip.AppendBd(pathInZip, byteData);
This method is deprecated. Applications should instead call AddBd.
Appends the contents of byteData as a new entry to this zip object. The zip entry object containing the data is returned.
Returns None on failure
AppendData Deprecated
# fileName is a string
# inData is a CkByteData
ret_zipEntry = zip.AppendData(fileName, inData);
This method is deprecated. Applications should instead call AddData.
Appends in-memory data as a new entry to a Zip object. The ZipEntry object containing the data is returned.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns None on failure
AppendDataEncoded
# filename is a string
# encoding is a string
# data is a string
ret_zipEntry = zip.AppendDataEncoded(filename, encoding, data);
This method is deprecated. Applications should instead call AddEncoded.
Appends in-memory data as a new entry to a Zip object. The filename is the filename of the entry as it will appear within the zip. The encoding is the encoding of the data, such as base64, hex, etc. The full list of encodings is listed at the web page linked below.
Returns the zip entry object.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns None on failure
AppendNew
This method is deprecated. Applications should instead call AddEmpty.
Appends a new and empty entry to the Zip object and returns the ZipEntry object. Data can be appended to the entry by calling ZipEntry.AppendData.
Important: To append an already-existing file, call the AppendOneFileOrDir method. The AppendNew method inserts a new and empty file entry within the Zip object. The purpose of AppendNew is to either create an empty file within the Zip, or to create a new file entry which can then be filled with data by calling the entry's AppendData method.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns None on failure
AppendNewDir
This method is deprecated. Applications should instead call AddEmpty.
Adds an entry to the zip so that when it unzips, a new directory (with no files) is created. The directory does not need to exist on the local filesystem when calling this method. The dirName is simply a string that is used as the directory path for the entry added to the zip. The zip entry object is returned.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns None on failure
AppendOneFileOrDir
# saveExtraPath is a boolean
status = zip.AppendOneFileOrDir(fileOrDirPath, saveExtraPath);
This method is deprecated. Applications should instead call AddFile.
Adds a file or directory to the object. If fileOrDirPath is an absolute file path and saveExtraPath is true, fileOrDirPath is converted to a relative file path for the zip entry. Otherwise, only the filename is stored. If fileOrDirPath is a relative file path, it is stored as-is in the zip, regardless of saveExtraPath.
Returns True for success, False for failure.
AppendOneFileOrDirAsync (1)
# fileOrDirPath is a string
# saveExtraPath is a boolean
ret_task = zip.AppendOneFileOrDirAsync(fileOrDirPath, saveExtraPath);
Creates an asynchronous task to call the AppendOneFileOrDir method with the arguments provided.
Returns None on failure
AppendSb
# sb is a CkStringBuilder
# charset is a string
status = zip.AppendSb(pathInZip, sb, charset);
This method is deprecated. Applications should instead call AddSb.
Same as AppendString, but append the contents of of the sb, and allow the charset to be specified. The contents of sb is converted to charset before being added to the zip. The pathInZip is the path of the file that will be stored within the zip.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns True for success, False for failure.
AppendString
# internalZipFilepath is a string
# textData is a string
ret_zipEntry = zip.AppendString(internalZipFilepath, textData);
This method is deprecated. Applications should instead call AddString.
Adds an in-memory string to the Zip object. The textData argument is converted to the ANSI charset before being added to the Zip. If the Zip were written to disk by calling WriteZip, and later unzipped, the entry would unzip to an ANSI text file.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns None on failure
AppendString2
# internalZipFilepath is a string
# textData is a string
# charset is a string
ret_zipEntry = zip.AppendString2(internalZipFilepath, textData, charset);
This method is deprecated. Applications should instead call AddString.
Same as AppendString, but allows the charset to be specified. The textData is converted to charset before being added to the zip. The internalZipFilepath is the path of the file that will be stored within the zip.
Note: This method only updates the zip object. To update (rewrite) a zip file, either the WriteZip or WriteZipAndClose method would need to be called.
Returns None on failure
FirstEntry
This method is deprecated. Applications should instead call EntryAt.
Return the first entry in the Zip. Call ZipEntry.NextEntry to iterate over the entries in a Zip until a NULL is returned.
Returns None on failure
FirstMatchingEntry
This method is deprecated. Applications should instead call EntryMatching.
Returns the first entry having a filename matching a pattern. The * characters matches 0 or more of any character. The full filename, including path, is used when matching against the pattern. A NULL is returned if nothing matches.
Returns None on failure
GetEntryByID
This method is deprecated. Applications should instead call EntryById.
Finds and returns the entry with the given entryID. (Each entry within the zip object has a unique EntryID.)
Returns None on failure
GetEntryByIndex
This method is deprecated. Applications should instead call EntryAt.
Retrieves a ZipEntry by index. The first entry is at index 0. This will return directory entries as well as files.
Returns None on failure
GetEntryByName
This method is deprecated. Applications should instead call EntryOf.
Returns the entry where the file path stored within the zip equals entryName.
Returns None on failure
GetExclusions
This method is deprecated and will removed in a future version of Chilkat.
Returns the current collection of exclusion patterns that have been set by SetExclusions.
Returns None on failure
OpenFromByteData Deprecated
Opens a ZIP archive from in-memory byte data.
When the ZIP archive is opened:
PasswordProtectis automatically set if legacy password protection is detected.Encryptionis automatically set if strong encryption is detected.Encryption = 4indicates AES encryption.
Returns True for success, False for failure.
topOpenFromMemory Deprecated
Opens a ZIP archive directly from in-memory binary data.
This allows ZIP processing without using filesystem files.
Typical use cases include:
- ZIP data loaded from a database
- ZIP data received from HTTP responses
- ZIP data stored entirely in memory
When the ZIP archive is opened:
PasswordProtectis automatically set if Zip 2.0 encryption is detected.Encryptionis automatically set if strong encryption is detected.
Returns True for success, False for failure.
SetPassword
zip.SetPassword(password);
Sets both the decrypt password and encrypt password.
This method affects:
DecryptPasswordEncryptPassword
Note: This method is deprecated in favor of setting DecryptPassword and EncryptPassword separately.
WriteExeToMemory Deprecated
(Relevant only when running on a Microsoft Windows operating system.) Same as WriteExe, but instead of writing a file, the MS-Windows EXE is written to memory.
Returns True for success, False for failure.
WriteExeToMemoryAsync Deprecated (1)
Creates an asynchronous task to call the WriteExeToMemory method with the arguments provided.
Returns None on failure
WriteToMemory Deprecated
Same as WriteZip, but instead of writing the Zip to a file, it writes to memory. Zips that are written to memory can also be opened from memory by calling OpenFromMemory.
Returns True for success, False for failure.
topWriteToMemoryAsync Deprecated (1)
Creates an asynchronous task to call the WriteToMemory method with the arguments provided.
Returns None on failure