Class Zip
- All Implemented Interfaces:
AutoCloseable
Create, read, modify, encrypt, and extract ZIP archives.
Chilkat.Zip provides a comprehensive API for working with ZIP
archives from files, memory, BinData, embedded resources, and
Windows self-extracting EXEs. It can create new archives, open existing ZIPs,
add files or in-memory data, inspect entries, extract selectively, and write
the final archive to disk or memory.
Create ZIP archives
Add files, directories, strings, byte arrays, BinData, and
StringBuilder content.
Open ZIPs from many sources
Open archives from disk, memory, BinData, embedded Windows
resources, or Chilkat-created self-extracting EXEs.
Control stored paths
Use options such as AppendFromDir, DiscardPaths,
PathPrefix, and saveExtraPath.
Extract selectively
Extract all files, matching entries, newer files, or flatten all output into a single directory.
Encryption support
Work with WinZip-compatible AES encryption and legacy Zip 2.0 password protection.
Large archive support
ZIP64 is used automatically when older ZIP limits are exceeded.
Important:
Many methods update the in-memory ZIP object first. The archive is not
written until a method such as WriteZip,
WriteZipAndClose, WriteBd, or
WriteToMemory is called.
For an extended overview, see Zip Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the contents of aBinDataobject as a new entry in the ZIP archive.voidAdds an empty file or directory entry to the ZIP archive.voidaddEncoded(String pathInZip, String encoding, String data)Adds encoded binary data as a ZIP entry.voidAdds a file or directory from the local filesystem to the ZIP archive.voidaddNoCompressExtension(String fileExtension)Adds a file extension to the internal "no-compression" list.voidaddSb(String pathInZip, StringBuilder sb, String charset)Adds the contents of aStringBuilderobject as a text entry in the ZIP archive.voidAdds a string as a text file entry in the ZIP archive.voidappendFiles(String filePattern, boolean recurse)Adds one or more files matching a wildcard pattern.voidappendFilesEx(String filePattern, boolean recurse, boolean saveExtraPath, boolean archiveOnly, boolean includeHidden, boolean includeSystem)Advanced version ofAppendFileswith additional filtering and path options.voidNote: This method is currently not working and will be fixed in v11.5.0voidcloseZip()Closes the currently open ZIP archive and clears all entries from the Zip object.voiddeleteEntry(ZipEntry entry)Removes a ZIP entry from the current ZIP object.voidRetrieves the ZIP entry at the specified zero-based index.voidFinds a ZIP entry by its unique EntryID.voidentryMatching(String pattern, ZipEntry entry)Finds the first ZIP entry whose stored path matches a wildcard pattern.booleanFinds a ZIP entry whose stored path exactly matchespathInZip.voidexcludeDir(String dirName)Adds a directory name to the exclusion list used by recursive append operations.voidextractExe(String exePath, String dirPath)Extracts files from a Chilkat-created self-extracting EXE.booleanStops the currently executing operation when set to.trueSpecifies a base directory when adding files to the ZIP.(Windows only, for creating self-extracting EXE's)(Windows only, for creating self-extracting EXE's)boolean(Windows only, for creating self-extracting EXE's)booleanControls whether filename matching is case-sensitive.boolean(Windows only)booleanIf, removes the read-only attribute from extracted files.trueSets or retrieves the global ZIP file comment.Password used to extract encrypted ZIP archives.Returns the ZIP directory structure as an XML document.booleanIf, removes all directory path information when adding files.trueintSpecifies encryption mode:0→ No encryption4→ WinZip-compatible AES encryptionintSpecifies the AES encryption key length.Password used when creating encrypted ZIP archives.getExeConfigParam(String name)(Windows only, for creating self-extracting EXE's)(Windows only, for creating self-extracting EXE's)boolean(Windows only, for creating self-extracting EXE's)(Windows only, for creating self-extracting EXE's)boolean(Windows only, for creating self-extracting EXE's)boolean(Windows only, for creating self-extracting EXE's)(Windows only, for creating self-extracting EXE's)(Windows only, for creating self-extracting EXE's)(Windows only, for creating self-extracting EXE's)booleanIf, waits for the AutoRun executable to finish before exiting.trueAllows for an XML config document to be used to specify all possible options for self-extracting EXEs.intNumber of files in the ZIP, excluding directory entries.Path of the ZIP file to be written or overwritten.booleanIndicates whether minor ZIP format problems were detected when opening the ZIP archive.intInterval, in milliseconds, between abort-check callbacks.booleanIf, files that cannot be read, written, or created due to filesystem permission errors are skipped.trueMaximum last-modified timestamp for files processed during add or extract operations.Returns the largest uncompressed file size contained within the ZIP archive.longPrevents extraction of files larger than the specified uncompressed size.Minimum last-modified timestamp for files processed during add or extract operations.intTotal number of entries in the ZIP, including both files and directories.intSpecifies the OEM code page used for ZIP filename encoding.booleanIf, existing files are overwritten during extraction.truebooleanIndicates whether the ZIP uses legacy Zip 2.0 password protection.Gets or sets a path prefix that is prepended to ZIP entry paths for files appended from the local filesystem.intControls the granularity of PercentDone event callbacks.Returns the installed listener, ornull.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.Directory used for temporary files during ZIP operations.Advanced options for uncommon scenarios.booleangetZipx()If, creates ZIPX archives using the most appropriate compression method for each file.trueDefault compression algorithm used when creating ZIPX archives.booleanisNoCompressExtension(String fileExtension)Checks whether a file extension is contained in the internal "no-compression" extension list.booleanisPasswordProtected(String zipPath)Checks whether a ZIP archive uses legacy Zip 2.0 password protection.voidInitializes a new empty ZIP archive.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.voidOpens a ZIP archive contained entirely within aBinDataobject.voidopenEmbedded(String exeFilename, String resourceName)(Windows only)voidOpens a ZIP archive from the local filesystem.voidquickAppend(String zipPath)Efficiently appends additional entries to an existing ZIP archive.voidremoveNoCompressExtension(String fileExtension)Removes a file extension from the internal "no-compression" extension list.voidsetAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().voidsetAppendFromDir(String value)Sets theAppendFromDirproperty; seegetAppendFromDir().voidsetAutoRun(String value)Sets theAutoRunproperty; seegetAutoRun().voidsetAutoRunParams(String value)Sets theAutoRunParamsproperty; seegetAutoRunParams().voidsetAutoTemp(boolean value)Sets theAutoTempproperty; seegetAutoTemp().voidsetCaseSensitive(boolean value)Sets theCaseSensitiveproperty; seegetCaseSensitive().voidsetClearArchiveAttribute(boolean value)Sets theClearArchiveAttributeproperty; seegetClearArchiveAttribute().voidsetClearReadOnlyAttr(boolean value)Sets theClearReadOnlyAttrproperty; seegetClearReadOnlyAttr().voidsetComment(String value)Sets theCommentproperty; seegetComment().voidsetCompressionLevel(int level)Sets the compression level for all file and data entries currently contained within the ZIP object.voidsetDecryptPassword(String value)Sets theDecryptPasswordproperty; seegetDecryptPassword().voidsetDiscardPaths(boolean value)Sets theDiscardPathsproperty; seegetDiscardPaths().voidsetEncryption(int value)Sets theEncryptionproperty; seegetEncryption().voidsetEncryptKeyLength(int value)Sets theEncryptKeyLengthproperty; seegetEncryptKeyLength().voidsetEncryptPassword(String value)Sets theEncryptPasswordproperty; seegetEncryptPassword().voidsetExclusions(StringArray excludePatterns)Specifies a collection of wildcard exclusion patterns used when adding files to the ZIP archive.voidsetExeConfigParam(String paramName, String paramValue)(Windows only, for creating self-extracting EXE's)voidsetExeDefaultDir(String value)Sets theExeDefaultDirproperty; seegetExeDefaultDir().voidsetExeFinishNotifier(boolean value)Sets theExeFinishNotifierproperty; seegetExeFinishNotifier().voidsetExeIconFile(String value)Sets theExeIconFileproperty; seegetExeIconFile().voidsetExeNoInterface(boolean value)Sets theExeNoInterfaceproperty; seegetExeNoInterface().voidsetExeSilentProgress(boolean value)Sets theExeSilentProgressproperty; seegetExeSilentProgress().voidsetExeTitle(String value)Sets theExeTitleproperty; seegetExeTitle().voidsetExeUnzipCaption(String value)Sets theExeUnzipCaptionproperty; seegetExeUnzipCaption().voidsetExeUnzipDir(String value)Sets theExeUnzipDirproperty; seegetExeUnzipDir().voidsetExeWaitForSetup(boolean value)Sets theExeWaitForSetupproperty; seegetExeWaitForSetup().voidsetExeXmlConfig(String value)Sets theExeXmlConfigproperty; seegetExeXmlConfig().voidsetFileName(String value)Sets theFileNameproperty; seegetFileName().voidsetHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().voidsetIgnoreAccessDenied(boolean value)Sets theIgnoreAccessDeniedproperty; seegetIgnoreAccessDenied().voidsetMaxDate(String value)Sets theMaxDateproperty; seegetMaxDate().voidsetMaxUncompressSize(long value)Sets theMaxUncompressSizeproperty; seegetMaxUncompressSize().voidsetMinDate(String value)Sets theMinDateproperty; seegetMinDate().voidsetOemCodePage(int value)Sets theOemCodePageproperty; seegetOemCodePage().voidsetOverwriteExisting(boolean value)Sets theOverwriteExistingproperty; seegetOverwriteExisting().voidsetPasswordProtect(boolean value)Sets thePasswordProtectproperty; seegetPasswordProtect().voidsetPathPrefix(String value)Sets thePathPrefixproperty; seegetPathPrefix().voidsetPercentDoneScale(int value)Sets thePercentDoneScaleproperty; seegetPercentDoneScale().voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidsetPwdProtCharset(String value)Sets thePwdProtCharsetproperty; seegetPwdProtCharset().voidsetTempDir(String value)Sets theTempDirproperty; seegetTempDir().voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsetZipx(boolean value)Sets theZipxproperty; seegetZipx().voidsetZipxDefaultAlg(String value)Sets theZipxDefaultAlgproperty; seegetZipxDefaultAlg().intExtracts all files and directories from the ZIP archive.intExtracts all files into a single directory.intunzipMatching(String dirPath, String pattern, boolean verbose)Extracts only entries whose stored paths match a wildcard pattern.intunzipMatchingInto(String dirPath, String pattern, boolean verbose)Extracts matching entries into a single directory while ignoring all stored ZIP path information.intunzipNewer(String dirPath)Extracts only files that: Do not already exist Or have older modification timestamps than the ZIP entrybooleanVerifies that the currentDecryptPasswordvalue is correct for the currently opened ZIP archive.voidWrites the ZIP archive to aBinDataobject instead of a filesystem file.void(Windows only, for creating self-extracting EXE's)voidwriteZip()Saves the Zip to a file and implictly re-opens it so further operations can continue.voidSaves the Zip to a file and closes it.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Zip
public Zip()Creates a newZipobject.
-
-
Method Details
-
getAbortCurrent
public boolean getAbortCurrent()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
- Returns:
- the value of the
AbortCurrentproperty
-
setAbortCurrent
public void setAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().- Parameters:
value- the new value
-
getAppendFromDir
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 toc:/abc/123, andmyAppDir/*would be passed toAppendFiles.The path stored in the ZIP would begin with
myAppDir/.- Returns:
- the value of the
AppendFromDirproperty
-
setAppendFromDir
Sets theAppendFromDirproperty; seegetAppendFromDir().- Parameters:
value- the new value (notnull)
-
getAutoRun
(Windows only, for creating self-extracting EXE's)Specifies the name of an executable inside a self-extracting EXE that runs automatically after extraction.
- Returns:
- the value of the
AutoRunproperty
-
setAutoRun
Sets theAutoRunproperty; seegetAutoRun().- Parameters:
value- the new value (notnull)
-
getAutoRunParams
(Windows only, for creating self-extracting EXE's)Command-line arguments passed to the
AutoRunexecutable.- Returns:
- the value of the
AutoRunParamsproperty
-
setAutoRunParams
Sets theAutoRunParamsproperty; seegetAutoRunParams().- Parameters:
value- the new value (notnull)
-
getAutoTemp
public boolean getAutoTemp()(Windows only, for creating self-extracting EXE's)If
, the EXE being created will automatically select and create a temporary directory for unzipping.trueThis property is often used together with
AutoRunto create a self-extracting EXE that automatically unzips to a temporary directory and runs a setup program, such assetup.exe, without user interaction.Note: To create a self-extracting EXE with no user interaction, set the following properties:
ExeSilentProgress =false
ExeNoInterface =true
ExeFinishNotifier =falseThe default value is
.false- Returns:
- the value of the
AutoTempproperty
-
setAutoTemp
public void setAutoTemp(boolean value)Sets theAutoTempproperty; seegetAutoTemp().- Parameters:
value- the new value
-
getCaseSensitive
public boolean getCaseSensitive()Controls whether filename matching is case-sensitive.- Affects methods such as
EntryMatchingandUnzipMatching. - Default:
false
- Returns:
- the value of the
CaseSensitiveproperty
- Affects methods such as
-
setCaseSensitive
public void setCaseSensitive(boolean value)Sets theCaseSensitiveproperty; seegetCaseSensitive().- Parameters:
value- the new value
-
getClearArchiveAttribute
public boolean getClearArchiveAttribute()(Windows only)If
, clears the Windows archive attribute after files are successfully added to the ZIP.trueThe archive attribute indicates that a file has changed since the last backup.
The default value is
.false- Returns:
- the value of the
ClearArchiveAttributeproperty
-
setClearArchiveAttribute
public void setClearArchiveAttribute(boolean value)Sets theClearArchiveAttributeproperty; seegetClearArchiveAttribute().- Parameters:
value- the new value
-
getClearReadOnlyAttr
public boolean getClearReadOnlyAttr()If, removes the read-only attribute from extracted files.trueIf
, the read-only attribute remains unchanged.falseThe default value is
.false- Returns:
- the value of the
ClearReadOnlyAttrproperty
-
setClearReadOnlyAttr
public void setClearReadOnlyAttr(boolean value)Sets theClearReadOnlyAttrproperty; seegetClearReadOnlyAttr().- Parameters:
value- the new value
-
getComment
Sets or retrieves the global ZIP file comment.The default value is the empty string.
- Returns:
- the value of the
Commentproperty
-
setComment
Sets theCommentproperty; seegetComment().- Parameters:
value- the new value (notnull)
-
getDecryptPassword
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.
- Returns:
- the value of the
DecryptPasswordproperty
-
setDecryptPassword
Sets theDecryptPasswordproperty; seegetDecryptPassword().- Parameters:
value- the new value (notnull)
-
getDiscardPaths
public boolean getDiscardPaths()If, removes all directory path information when adding files.trueOnly filenames are stored in the ZIP.
The default value is
.false- Returns:
- the value of the
DiscardPathsproperty
-
setDiscardPaths
public void setDiscardPaths(boolean value)Sets theDiscardPathsproperty; seegetDiscardPaths().- Parameters:
value- the new value
-
getEncryptKeyLength
public int getEncryptKeyLength()Specifies the AES encryption key length.- Valid values:
128,192, or256
The default value is
128.- Returns:
- the value of the
EncryptKeyLengthproperty
- Valid values:
-
setEncryptKeyLength
public void setEncryptKeyLength(int value)Sets theEncryptKeyLengthproperty; seegetEncryptKeyLength().- Parameters:
value- the new value
-
getEncryptPassword
Password used when creating encrypted ZIP archives.The default value is the empty string.
- Returns:
- the value of the
EncryptPasswordproperty
-
setEncryptPassword
Sets theEncryptPasswordproperty; seegetEncryptPassword().- Parameters:
value- the new value (notnull)
-
getEncryption
public int getEncryption()Specifies encryption mode:0→ No encryption4→ WinZip-compatible AES encryption
Important:
EncryptionandPasswordProtectare mutually exclusive.If
PasswordProtect =, thentrueEncryptionshould be0.The default value is
0.- Returns:
- the value of the
Encryptionproperty
-
setEncryption
public void setEncryption(int value)Sets theEncryptionproperty; seegetEncryption().- Parameters:
value- the new value
-
getExeDefaultDir
(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.
- Returns:
- the value of the
ExeDefaultDirproperty
-
setExeDefaultDir
Sets theExeDefaultDirproperty; seegetExeDefaultDir().- Parameters:
value- the new value (notnull)
-
getExeFinishNotifier
public boolean getExeFinishNotifier()(Windows only, for creating self-extracting EXE's)If
, displays a completion dialog after extraction finishes.trueThe default value is
.false- Returns:
- the value of the
ExeFinishNotifierproperty
-
setExeFinishNotifier
public void setExeFinishNotifier(boolean value)Sets theExeFinishNotifierproperty; seegetExeFinishNotifier().- Parameters:
value- the new value
-
getExeIconFile
(Windows only, for creating self-extracting EXE's)Path to an
.icofile 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.
- Returns:
- the value of the
ExeIconFileproperty
-
setExeIconFile
Sets theExeIconFileproperty; seegetExeIconFile().- Parameters:
value- the new value (notnull)
-
getExeNoInterface
public boolean getExeNoInterface()(Windows only, for creating self-extracting EXE's)If
, runs the self-extracting EXE without displaying the main user interface.trueThe default value is
.false- Returns:
- the value of the
ExeNoInterfaceproperty
-
setExeNoInterface
public void setExeNoInterface(boolean value)Sets theExeNoInterfaceproperty; seegetExeNoInterface().- Parameters:
value- the new value
-
getExeSilentProgress
public boolean getExeSilentProgress()(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.falseThe default value is
.false- Returns:
- the value of the
ExeSilentProgressproperty
-
setExeSilentProgress
public void setExeSilentProgress(boolean value)Sets theExeSilentProgressproperty; seegetExeSilentProgress().- Parameters:
value- the new value
-
getExeTitle
(Windows only, for creating self-extracting EXE's)Title displayed in the self-extracting EXE dialog.
The default value is the empty string.
- Returns:
- the value of the
ExeTitleproperty
-
setExeTitle
Sets theExeTitleproperty; seegetExeTitle().- Parameters:
value- the new value (notnull)
-
getExeUnzipCaption
(Windows only, for creating self-extracting EXE's)Caption text displayed in the self-extracting EXE dialog.
The default value is the empty string.
- Returns:
- the value of the
ExeUnzipCaptionproperty
-
setExeUnzipCaption
Sets theExeUnzipCaptionproperty; seegetExeUnzipCaption().- Parameters:
value- the new value (notnull)
-
getExeUnzipDir
(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.
- Returns:
- the value of the
ExeUnzipDirproperty
- Supports environment variables such as
-
setExeUnzipDir
Sets theExeUnzipDirproperty; seegetExeUnzipDir().- Parameters:
value- the new value (notnull)
-
getExeWaitForSetup
public boolean getExeWaitForSetup()If, waits for the AutoRun executable to finish before exiting.trueIf
, the self-extracting EXE may exit before the AutoRun executable completes.falseThe default value is
.true- Returns:
- the value of the
ExeWaitForSetupproperty
-
setExeWaitForSetup
public void setExeWaitForSetup(boolean value)Sets theExeWaitForSetupproperty; seegetExeWaitForSetup().- Parameters:
value- the new value
-
getExeXmlConfig
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:
<SfxConfig>
<ErrPwdTitle>Title for incorrect password dialog</ErrPwdTitle>
<ErrPwdCaption>Caption for incorrect password dialog</ErrPwdCaption>
<FinOkBtn>Text on finish notifier button</FinOkBtn>
<PwdOkBtn>Text on password challenge dialog's "OK" button.</PwdOkBtn>
<PwdCancelBtn>Text on password challenge dialog's Cancel button.</PwdCancelBtn>
<ErrInvalidPassword>Incorrect password error message.</ErrInvalidPassword>
<MainUnzipBtn>Text on main dialog's unzip button. Note: The
MainUnzipLabelmust also be set for this to take effect.</MainUnzipBtn><MainCloseBtn>Text on main dialog's quit/exit button. Note: The
MainUnzipLabelmust also be set for this to take effect.</MainCloseBtn><MainBrowseBtn>Text on main dialog's browse-for-directory button. Note: The
MainUnzipLabelmust also be set for this to take effect.</MainBrowseBtn><MainUnzipLabel>Caption displayed in main dialog.</MainUnzipLabel>
<AutoTemp>0 or 1 (Maps to the
AutoTempproperty)</AutoTemp><Cleanup>0 or 1 (If 1, extracted files are deleted after the
SetupExeis run.)</Cleanup><Debug>0 or 1 (If 1, the EXE will not extract any files.)</Debug>
<Verbose>0 or 1 (If 1, verbose information is written to the log.)</Verbose>
<ShowFin>0 or 1 (Maps to the
ExeFinishNotifierproperty)</ShowFin><ShowMain>0 or 1 (Maps to the
ExeNoInterfaceproperty)</ShowMain><ShowProgress>0 or 1 (Maps to the
ExeSilentProgressproperty)</ShowProgress><WaitForSetup>0 or 1 (Maps to the
ExeWaitForSetupproperty)</WaitForSetup><Encryption>0 or 1 (1 = Yes, 0 = No)</Encryption>
<KeyLength>128|192|256</KeyLength>
<SetupExe>EXE to run after extracting. (Maps to the
AutoRunproperty)</SetupExe><UnzipDir>Pre-defined unzip directory. (Maps to the
ExeUnzipDirproperty. UNC paths, such as \\servername\path, are not supported.)</UnzipDir><DefaultDir>Default unzip directory to appear in the main dialog. (Maps to the
ExeDefaultDirproperty)</DefaultDir><IconFile>Icon file to be used (Maps to the
ExeIconFileproperty)</IconFile><MainTitle>Maps to the
ExeTitleproperty.</MainTitle><MainCaption>Maps to the
ExeUnzipCaptionproperty.</MainCaption><FinTitle>Title for the finish notifier dialog.</FinTitle>
<FinCaption>Caption for the finish notifier dialog.</FinCaption>
<ProgressTitle>Title for the progress dialog.</ProgressTitle>
<ProgressCaption>Caption for the progress dialog.</ProgressCaption>
<PwTitle>Title for the password challenge dialog.</PwTitle>
<PwCaption>Caption for the password challenge dialog.</PwCaption>
</SfxConfig>
A self-extracting EXE can be run from the command line with the
-log {logFilePath}option to create a log with information for debugging.- Returns:
- the value of the
ExeXmlConfigproperty
-
setExeXmlConfig
Sets theExeXmlConfigproperty; seegetExeXmlConfig().- Parameters:
value- the new value (notnull)
-
getFileCount
public int getFileCount()Number of files in the ZIP, excluding directory entries.- Returns:
- the value of the
FileCountproperty (read-only)
-
getFileName
Path of the ZIP file to be written or overwritten.The default value is the empty string.
- Returns:
- the value of the
FileNameproperty
-
setFileName
Sets theFileNameproperty; seegetFileName().- Parameters:
value- the new value (notnull)
-
getHasZipFormatErrors
public boolean getHasZipFormatErrors()Indicates whether minor ZIP format problems were detected when opening the ZIP archive.- Returns:
- the value of the
HasZipFormatErrorsproperty (read-only)
-
getHeartbeatMs
public int getHeartbeatMs()Interval, in milliseconds, between abort-check callbacks.If set to
0, abort callbacks are disabled.The default value is
0.- Returns:
- the value of the
HeartbeatMsproperty
-
setHeartbeatMs
public void setHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().- Parameters:
value- the new value
-
getIgnoreAccessDenied
public boolean getIgnoreAccessDenied()If, files that cannot be read, written, or created due to filesystem permission errors are skipped.trueIf
, any access-denied error causes the ZIP operation to fail.falseThe default value is
.true- Returns:
- the value of the
IgnoreAccessDeniedproperty
-
setIgnoreAccessDenied
public void setIgnoreAccessDenied(boolean value)Sets theIgnoreAccessDeniedproperty; seegetIgnoreAccessDenied().- Parameters:
value- the new value
-
getMaxDate
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.
- Returns:
- the value of the
MaxDateproperty
-
setMaxDate
Sets theMaxDateproperty; seegetMaxDate().- Parameters:
value- the new value (notnull)
-
getMaxUncompressSize
public long getMaxUncompressSize()Prevents extraction of files larger than the specified uncompressed size.A value of
0means no size limit.The default value is
0.- Returns:
- the value of the
MaxUncompressSizeproperty
-
setMaxUncompressSize
public void setMaxUncompressSize(long value)Sets theMaxUncompressSizeproperty; seegetMaxUncompressSize().- Parameters:
value- the new value (0 .. 4294967295)
-
getMinDate
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.
- Returns:
- the value of the
MinDateproperty
-
setMinDate
Sets theMinDateproperty; seegetMinDate().- Parameters:
value- the new value (notnull)
-
getNumEntries
public int getNumEntries()Total number of entries in the ZIP, including both files and directories.- Returns:
- the value of the
NumEntriesproperty (read-only)
-
getOemCodePage
public int getOemCodePage()Specifies the OEM code page used for ZIP filename encoding.Defaults to the OEM code page of the current computer.
- Returns:
- the value of the
OemCodePageproperty
-
setOemCodePage
public void setOemCodePage(int value)Sets theOemCodePageproperty; seegetOemCodePage().- Parameters:
value- the new value
-
getOverwriteExisting
public boolean getOverwriteExisting()If, existing files are overwritten during extraction.trueThe default value is
.true- Returns:
- the value of the
OverwriteExistingproperty
-
setOverwriteExisting
public void setOverwriteExisting(boolean value)Sets theOverwriteExistingproperty; seegetOverwriteExisting().- Parameters:
value- the new value
-
getPasswordProtect
public boolean getPasswordProtect()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 asOpenZip,OpenFromMemory,OpenBd, and related methods.Important:
PasswordProtectandEncryptionare mutually exclusive.If
PasswordProtect =, thentrueEncryptionshould be0.The default value is
.false- Returns:
- the value of the
PasswordProtectproperty
-
setPasswordProtect
public void setPasswordProtect(boolean value)Sets thePasswordProtectproperty; seegetPasswordProtect().- Parameters:
value- the new value
-
getPathPrefix
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
PathPrefixvalue 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.
- Returns:
- the value of the
PathPrefixproperty
-
-
setPathPrefix
Sets thePathPrefixproperty; seegetPathPrefix().- Parameters:
value- the new value (notnull)
-
getPercentDoneScale
public int getPercentDoneScale()Controls the granularity of PercentDone event callbacks.This property is only applicable in programming environments that support event callbacks.
The value specifies what should be considered
100%complete for progress reporting purposes.- A value of
100provides whole-percent progress updates. - A value of
1000provides tenth-percent granularity. - For example, with a scale of
1000, a PercentDone callback value of453represents45.3%complete.
Increasing this value allows for more frequent and finer-grained progress callbacks during long-running operations.
The value is automatically clamped to the range:
- Minimum:
10 - Maximum:
100000
The default value is
100.- Returns:
- the value of the
PercentDoneScaleproperty
- A value of
-
setPercentDoneScale
public void setPercentDoneScale(int value)Sets thePercentDoneScaleproperty; seegetPercentDoneScale().- Parameters:
value- the new value
-
getPwdProtCharset
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.
- Returns:
- the value of the
PwdProtCharsetproperty
-
setPwdProtCharset
Sets thePwdProtCharsetproperty; seegetPwdProtCharset().- Parameters:
value- the new value (notnull)
-
getTempDir
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.
- Returns:
- the value of the
TempDirproperty
-
setTempDir
Sets theTempDirproperty; seegetTempDir().- Parameters:
value- the new value (notnull)
-
getUncommonOptions
Advanced options for uncommon scenarios.ForceZip64→ Forces ZIP64 format even when not required.
The default value is the empty string.
- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
getZipx
public boolean getZipx()If, creates ZIPX archives using the most appropriate compression method for each file.trueThe default value is
.false- Returns:
- the value of the
Zipxproperty
-
setZipx
public void setZipx(boolean value)Sets theZipxproperty; seegetZipx().- Parameters:
value- the new value
-
getZipxDefaultAlg
Default compression algorithm used when creating ZIPX archives.- Possible values include:
deflateppmdlzmabzip2deflate64
The default value is
deflate.- Returns:
- the value of the
ZipxDefaultAlgproperty
- Possible values include:
-
setZipxDefaultAlg
Sets theZipxDefaultAlgproperty; seegetZipxDefaultAlg().- Parameters:
value- the new value (notnull)
-
addBd
Adds the contents of aBinDataobject 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.
- Parameters:
pathInZip- thepathInZipargument (notnull)bd- thebdargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addEmpty
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.
- Parameters:
isDir- theisDirargumentpathInZip- thepathInZipargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- If
-
addEncoded
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.
- Parameters:
pathInZip- thepathInZipargument (notnull)encoding- theencodingargument (notnull)data- thedataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addFile
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.
- Parameters:
localPath- thelocalPathargument (notnull)saveExtraPath- thesaveExtraPathargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- If
-
addNoCompressExtension
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.- Parameters:
fileExtension- thefileExtensionargument (notnull)
-
addSb
Adds the contents of aStringBuilderobject 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.
- Parameters:
pathInZip- thepathInZipargument (notnull)sb- thesbargument (notnull)charset- thecharsetargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- The text is converted to bytes using the specified
-
addString
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.
- Parameters:
pathInZip- thepathInZipargument (notnull)content- thecontentargument (notnull)charset- thecharsetargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- The string is converted to bytes using the specified
-
appendFiles
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.- Parameters:
filePattern- thefilePatternargument (notnull)recurse- therecurseargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- The wildcard character
-
appendFilesEx
public void appendFilesEx(String filePattern, boolean recurse, boolean saveExtraPath, boolean archiveOnly, boolean includeHidden, boolean includeSystem)Advanced version ofAppendFileswith 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.- Parameters:
filePattern- thefilePatternargument (notnull)recurse- therecurseargumentsaveExtraPath- thesaveExtraPathargumentarchiveOnly- thearchiveOnlyargumentincludeHidden- theincludeHiddenargumentincludeSystem- theincludeSystemargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendZip
Note: This method is currently not working and will be fixed in v11.5.0Adds all entries from another existing ZIP archive into the current ZIP object.
The
zipPathargument 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.
- Parameters:
zipPath- thezipPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
closeZip
public void closeZip()Closes the currently open ZIP archive and clears all entries from the Zip object.This method has the same effect as calling
NewZipwithout 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.- Parameters:
entry- theentryargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
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.
- Parameters:
index- theindexargumententry- theentryargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- The first entry is at index
-
entryById
Finds a ZIP entry by its unique EntryID.The matching entry is returned in the supplied
ZipEntryobject.- Parameters:
id- theidargumententry- theentryargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
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.
- Parameters:
pattern- thepatternargument (notnull)entry- theentryargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- The wildcard character
-
entryOf
Finds a ZIP entry whose stored path exactly matchespathInZip.The matching entry is returned in the supplied
ZipEntryobject.- Parameters:
pathInZip- thepathInZipargument (notnull)entry- theentryargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
excludeDir
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
AppendFilesandAppendFilesEx.- Parameters:
dirName- thedirNameargument (notnull)
-
extractExe
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.
- Parameters:
exePath- theexePathargument (notnull)dirPath- thedirPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
- Files are extracted into
-
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:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getExeConfigParam
(Windows only, for creating self-extracting EXE's)Returns the value of a configuration parameter embedded within a self-extracting EXE.
The
nameargument should be one of the XML tag names described in theExeXmlConfigproperty documentation.For example:
MainTitleMainCaptionSetupExe
Returns the parameter value as a string.
- Parameters:
name- thenameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
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:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
isNoCompressExtension
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 returnstrue.false- Parameters:
fileExtension- thefileExtensionargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
isPasswordProtected
Checks whether a ZIP archive uses legacy Zip 2.0 password protection.The
zipPathargument 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 returnstrue.false- Parameters:
zipPath- thezipPathargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
newZip
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.
- Parameters:
zipPath- thezipPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
openBd
Opens a ZIP archive contained entirely within aBinDataobject.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.
- Parameters:
binData- thebinDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
openEmbedded
(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.
- Parameters:
exeFilename- theexeFilenameargument (notnull)resourceName- theresourceNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
openZip
Opens a ZIP archive from the local filesystem.The
zipPathargument 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.
- Parameters:
zipPath- thezipPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
quickAppend
Efficiently appends additional entries to an existing ZIP archive.The
zipPathargument 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.
- Parameters:
zipPath- thezipPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
removeNoCompressExtension
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.
- Parameters:
fileExtension- thefileExtensionargument (notnull)
-
setCompressionLevel
public void setCompressionLevel(int 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.
- Parameters:
level- thelevelargument
-
setExclusions
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.
- Parameters:
excludePatterns- theexcludePatternsargument (notnull)
-
setExeConfigParam
(Windows only, for creating self-extracting EXE's)Sets a configuration parameter embedded within a self-extracting EXE created by
WriteExeorWriteExe2.The
paramNameshould be one of the XML configuration tag names described in theExeXmlConfigproperty documentation.For example:
SetExeConfigParam("MainUnzipBtn","Extract")This changes the text displayed on the self-extractor's main unzip button.
- Parameters:
paramName- theparamNameargument (notnull)paramValue- theparamValueargument (notnull)
-
unzip
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
-1if a failure occurs.- Parameters:
dirPath- thedirPathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
unzipInto
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
-1on failure.- Parameters:
dirPath- thedirPathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
unzipMatching
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
-1on failure.- Parameters:
dirPath- thedirPathargument (notnull)pattern- thepatternargument (notnull)verbose- theverboseargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
- The wildcard character
-
unzipMatchingInto
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
-1on failure.- Parameters:
dirPath- thedirPathargument (notnull)pattern- thepatternargument (notnull)verbose- theverboseargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
unzipNewer
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
-1on failure.- Parameters:
dirPath- thedirPathargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
verifyPassword
public boolean verifyPassword()Verifies that the currentDecryptPasswordvalue is correct for the currently opened ZIP archive.This method allows password validation before attempting extraction.
Returns
if the password is valid, otherwise returnstrue.false- Returns:
- the result; this method never throws
ChilkatException
-
writeBd
Writes the ZIP archive to aBinDataobject 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.- Parameters:
binData- thebinDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
writeExe
(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
- Parameters:
exeFilename- theexeFilenameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
writeZip
public void 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.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
writeZipAndClose
public void 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.- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-