|

Chilkat
Zip Data Compression ActiveX Home
DOWNLOAD
Versions
Chilkat
Components:
Certificate
Crypt
XML
ASP XML Mail
MHT
S/MIME
Zip
SSL
RTC
Charset
CkStringArray
CkData
ChilkatCSP
Help
for Creating Objects in ASP
Zip
Data Compression Reference Guide
Unlocking
the Component
Properties
Creating, Loading, and Saving Zips
Adding to the Zip
Unzipping
Accessing Individual Entries
The XML Directory
AES Encryption
Embedding ZIPs into EXEs
Writing Self-Extracting EXEs
Properties
Access to Uncompressed Data
Access to Compressed Data
Replacing or Appending Data
Unzipping
Iterating
over the entries in a Zip
ChilkatZip
Unlocking
the Zip Component
To use Chilkat Zip,
you must first unlock it immediately after creating the object.
|
(Method)
UnlockComponent(UnlockCode As String)
This method must be called once at the beginning of a program
to unlock the component. A 30-day unlockCode can be obtained
from http://www.chilkatsoft.com/register30.asp.
TOP
(Method)
SaveXmlLog(filename
As String)
Easy way to save the error log (in XML
format) to a file. TOP
- (Property)
ErrorLogHtml As String read-only
- Detailed
error information for any accumulated errors. The error
information is formatted with <br> tags separating
lines of text. [top]
- (Property)
ErrorLogText As String read-only
- Detailed
error information for any accumulated errors. The error
information is formatted with CRLF line endings. [top]
- (Property)
ErrorLogXml As String read-only
- Detailed
error information for any accumulated errors. The error
information is formatted as XML. [top]
|
ChilkatZip
Properties
|
(Property)
AppendFromDir
As String
read/write
When
files are appended, they are appended from this directory.
TOP
(Property)
Comment
As String read/write
The comment stored within the Zip file header.
TOP
(Property)
FileName
As String read/write
The filename of the Zip.
TOP
(Property)
NumEntries
As Long read-only
The number of entries in the Zip, including directory entries.
TOP
(Property)
PasswordProtect
As Long read-write
Set to 1 if the Zip should be written with password protection.
Defaults to 0 (no password protection)
TOP
(Property)
Proxy
As String read-write
This property is used in conjunction with the OpenFromWeb
method. If your computer uses a proxy to access the Internet,
this is where you need to set the proxy. If a proxy is already
setup in Internet Explorer, it is not necessary to set this
property because Chilkat Zip will automatically use the
proxy setup for IE.
TOP
(Property)
TempDir
As String read/write
The temporary directory to use when unzipping files.
TOP
(Property)
Version
As String read-only
The version of the Zip component, such as "5.0.6"
TOP
|
ChilkatZip
Events
Events
will only be fired after UnlockComponent has been called with
a valid unlock code. After your 30-day unlock code expires, you
must purchase a license to continue using events.
|
(Event)
UnzipPercentDone(
ByVal
percentDone As Long)
Called
periodically when unzipping. PercentDone is a number from
0 to 100.
TOP
(Event)
WriteZipPercentDone(
ByVal
percentDone
As Long)
Called
periodically when zipping. PercentDone is a number from
0 to 100.
TOP
IMPORTANT:
Notice the distinction between "Zip object" and
"Zip file". The Append methods, such as AppendFileEx,
append files or memory data to the Chilkat Zip object. The
Zip file is not updated until WriteZip is called. When a
file is added to the Zip object, the contents of the file
are NOT loaded into memory, but rather a reference to the
file is saved, and this is used to stream the file into
the Zip (on disk) when WriteZip is called.
(Event)
AddFilesBegin(
)
Called
once before files are added to the Zip object. Methods that
cause this event to fire include AppendFiles, AppendFilesEx,
and AppendMultiple.
TOP
(Event)
ToBeAdded(
ByVal
filename
As String, ByVal
fileSize
As Long, exclude As Long)
Called
for each file to be added to the Zip object, but before
it is added. You can prevent the file from being added by
setting exclude to 1. Methods
that cause this event to fire include AppendFiles, AppendFilesEx,
and AppendMultiple.
TOP
(Event)
FileAdded(
ByVal
filename
As String, ByVal
fileSize
As Long, abort As Long)
Called
after each file to be added to the Zip object. You can prevent
any more files from being added by setting abort
to 1. Methods
that cause this event to fire include AppendFiles, AppendFilesEx,
and AppendMultiple.
TOP
(Event)
AddFilesEnd(
)
Called
when all files have been added to the Zip object. Methods
that cause this event to fire include AppendFiles, AppendFilesEx,
and AppendMultiple.
TOP
(Event)
WriteZipBegin(
)
Called
at the beginning of a WriteZip.
TOP
(Event)
ToBeZipped(
ByVal
filename
As String, ByVal
fileSize
As Long, exclude As Long)
Called
for each file during a WriteZip, before the file is compressed
and added to the Zip file. If exclude is set to 1,
the file is not added to the Zip file.
TOP
(Event)
FileZipped(
ByVal
filename
As String, ByVal
fileSize
As Long, ByVal compressedSize As Long, abort As Long)
Called
for each file during a WriteZip after the file has been
compressed and added to the Zip. If abort is set to 1, no
more files will be added to the Zip.
TOP
(Event)
WriteZipEnd(
)
Called
at the end of a WriteZip.
TOP
(Event)
UnzipBegin(
)
Called
at the beginning of Extract, ExtractNewer, or ExtractMatching.
TOP
(Event)
ToBeUnzipped(
ByVal
filename
As String, ByVal
compressedSize
As Long, ByVal uncompressedSize As Long, exclude As Long)
Called
for each file during an unzip, before the file is unzipped.
If exclude is set to 1, the file is not unzipped.
TOP
(Event)
FileUnzipped(
ByVal
filename
As String, ByVal
compressedSize
As Long, ByVal uncompressedSize As Long,
abort As Long)
Called
for each file after it is unzipped. If abort is set to 1,
the unzip operation will be aborted.
TOP
(Event)
WriteZipEnd(
)
Called
at the end of Extract, ExtractNewer, or ExtractMatching.
TOP
|
Creating,
Loading, and Saving Zip Files
|
(Method)
CloseZip( )
Closes the Zip and releases the Zip file if one was open
for reading and/or writing.
TOP
(Method)
NewZip(Filename As String)
Clears the contents of the Zip object, and initializes the
FileName property. This does not create a file on disk,
it simply initializes the Zip object to a new and empty
state.
TOP
(Method)
OpenFromMemory( ZipFileInMemory As Variant )
Loads the contents of a Zip file already loaded in memory,
into the Chilkat Zip object.
TOP
(Method)
OpenFromUrl( Url As String )
As Long
Opens a Zip directly from a URL on the Web. Returns 1 for
success, and 0 for failure. The Zip is downloaded and loaded
into memory, so the Zip cannot be so large such that it
will not fit into virtual memory or create unreasonable
download times for your application.
TOP
(Method)
OpenZip(FileName As String)
Loads the contents of a Zip file into the Chilkat Zip object.
TOP
(Method)
WriteZip(void)
Writes the Zip to disk using the FileName property for the
name of the file.
TOP
(Method)
WriteZipAndClose(void)
As Long
Writes the Zip to disk using the FileName property for the
name of the file.
Closes the Zip file after writing, putting the Zip object
in a state as if NewZip had been called. Returns 1 for success
and 0 for failure. TOP
|
Adding
to / Deleting from the Zip Object
The "Append"
methods add ChilkatZipEntry objects to the ChilkatZip object.
The files or memory data added by calling these methods are not
compressed and stored in the Zip file on disk until WriteZip is
called.
|
(Method)
AppendBase64(EntryFileName
As String, Base64Data As String) As ChilkatZipEntry
Creates a new Zip entry and initializes it with already-compressed
data that is base-64 encoded. The ChilkatZipEntry's FileName
property is initialized to EntryFileName.
TOP
(Method)
AppendCompressed(EntryFileName
As String, Data As Variant, DataLen As Long) As ChilkatZipEntry
Creates a new Zip entry and initializes it with already-compressed
data. The ChilkatZipEntry's FileName property is initialized
to EntryFileName.
TOP
(Method)
AppendData(EntryFileName
As String, Data As Variant, DataLen As Long) As ChilkatZipEntry
Creates a new Zip entry and initializes it with uncompressed
memory data. The ChilkatZipEntry's FileName property is
initialized to EntryFileName.
TOP
(Method)
AppendFiles(FilePattern As String, Recurse As Long) As ChilkatZipEntry
Appends one or more files to the Zip object. The FilePattern
can use the "*" or "?" wildcard characters.
"*" means 0 or more of any character, and "?"
means any single character. Set Recurse equal to 1 to recursively
add all subdirectories, or 0 to only add files in the current
directory.
TOP
(Method)
AppendFilesEx(FilePattern As String, Recurse
As Long, SaveExtraPath As Long, ArchiveOnly As Long, IncludeHidden
As Long, Include System As Long )
As ChilkatZipEntry
Same as AppendFiles, but extra parameters are to control
whether or not the full pathname is included with the Zip
entry, or whether files with the Archive, Hidden, or System
attributes are included. 1 = yes, 0 = no.
TOP
(Method)
AppendHex(EntryFileName
As String, HexStr As String) As ChilkatZipEntry
Creates a new Zip entry and initializes it with already-compressed
data that is hexidecimal encoded. The ChilkatZipEntry's
FileName property is initialized to EntryFileName.
TOP
(Method)
AppendMultiple(FilePatterns
As CkStringArray, Recurse As Long)
Same as calling AppendFiles multiple times - once for each
file pattern in the CkStringArray.
TOP
(Method)
AppendNew(EntryFileName As String) As ChilkatZipEntry
Appends a new and empty entry to the Zip object.
TOP
(Method)
AppendZip(ZipFileName
As String)
Append all the files from within another Zip file into this
one. TOP
(Method)
DeleteEntry(entry
As ChilkatZipEntry)
Removes an entry from the Zip object. The procedure for
removing a file from an existing Zip would be to (1) open
the ZIp, (2) remove the entry by calling this method, and
(3) writing the Zip.
TOP
(Method)
ExcludeDir(dirName
as String)
added in v9.8.0
Excludes an entire directory subtree when appending files
to a Zip. This can be called multiple times to exclude multiple
directory subtrees. The dirName should not contain path
information, and any directory whose name matches dirName
(case insensitive), regardless of where it it is found,
will be excluded. This should be called before calling AppendFiles
or AppendFilesEx.
(Method)
InsertNew(BeforeIndex
As Long, EntryFileName As String) As ChilkatZipEntry
Inserts a new and empty entry into the Zip object. To insert
at the beginning of the Zip, BeforeIndex should be 0. The
ChilkatZipEntry's FileName property is initialized to EntryFileName.
TOP
|
Unzipping
|
(Method)
Extract(Directory As String)
Unzip all the files into the specified directory. Subdirectories
are automatically created as needed.
TOP
(Method)
Extract2(Directory As String) As Long
This is the same as Extract, except a status is returned:
-1 = failure, otherwise it returns the number of files unzipped.
TOP
(Method)
ExtractInto(Directory As String) As Long
Unzip all the files into a single directory regardless of
the paths stored in the Zip.
TOP
(Method)
ExtractMatching(Directory
As String, FilePattern As String)
Extract all the files that match the pattern. Subdirectories
are automatically created as needed. The pattern can contain
any number of "*" or "?" wildcards.
"*" means 0 or more of any character, "?"
means any single character.
TOP
(Method)
ExtractNewer(Directory
As String)
Extracts only the files that have more recent last-modified-times
than the files on disk. This allows you to easily refresh
only the files that have been updated.
TOP
(Method)
SetExclusions(excludePatterns
As CkStringArray)
You can specify wildcarded patterns of files to exclude
from zipping, such as "*.log", which would prevent
any file ending in ".log" from being added to
a zip. Any number of exclusions can be added, and the exclusions
pertain to any of the Append* methods.
TOP
(Method)
GetExclusions()
As CkStringArray
Returns the array of exclusions previously set for this
Zip object.
TOP
(Method)
Unzip(Directory As String) As Long
Unzip all the files into the specified directory. Subdirectories
are automatically created as needed. Returns the number
of files unzipped or -1 for an error.
TOP
(Method)
UnzipInto(Directory
As String) As Long
Unzip all the files into a single directory regardless of
the paths stored in the Zip. Returns the number of files
unzipped or -1 for an error.
TOP
(Method)
UnzipMatching(Directory
As String, FilePattern As String,
Verbose As Long)
As Long
Unzips all the files that match the pattern. Subdirectories
are automatically created as needed. The pattern can contain
any number of "*" or "?" wildcards.
"*" means 0 or more of any character, "?"
means any single character. Returns the number of files
unzipped or -1 for an error.
If Verbose = 1, the log (see SaveXmlLog) will contain a
detailed list of the pattern matching comparisons that were
made. TOP
(Method)
UnzipMatchingInto(Directory
As String, FilePattern As String,
Verbose As Long)
As Long
Same as UnzipMatching except the files are unzipped into
a single directory as in UnzipInto. Returns the number of
files unzipped or -1 for an error. If Verbose = 1, the log
(see SaveXmlLog) will contain a detailed list of the pattern
matching comparisons that were made.
TOP
(Method)
UnzipNewer(Directory
As String)
As Long
Unzips only the files that have more recent last-modified-times
than the files on disk. This allows you to easily refresh
only the files that have been updated. Returns the number
of files unzipped or -1 for an error.
TOP
|
Accessing
Individual Zip Entries
|
(Method)
FirstMatchingEntry(FilePattern
As String) As ChilkatZipEntry
Returns
the first Zip entry whose filename matches the FilePattern.
The pattern can contain any number of "*" or "?"
wildcards. "*" means 0 or more of any character,
"?" means any single character.
TOP
(Method)
GetEntries(void)
As ChilkatEnum
Returns an enumeration object that can be used to enumerate
over the files in a Zip object.
TOP
(Method)
GetEntryByID(EntryID
As Long) As ChilkatZipEntry
Retrieves a Zip entry by ID. Chilkat Zip automatically assigns
a unique ID to each Zip entry in memory. The IDs are not
persisted to disk.
TOP
(Method)
GetEntryByIndex(Index
As Long) As ChilkatZipEntry
Returns a Zip entry by index. The first entry is at index
0. This will return directory entries as well as files.
(Use ChilkatEnum to enumerate over files, but not directories.)
TOP
(Method)
GetEntryByName(Filename
As String) As ChilkatZipEntry
Returns a Zip entry by filename.
TOP
|
The
XML Zip Directory
|
(Method)
GetDirectoryAsXML(void)
As String
Returns an XML formatted listing of the contents of the
Zip archive. An example is shown below:
<zip_contents>
<dir name="Images">
<file>flag.jpg</file>
</dir>
<dir name="Sounds">
<file>SOUND45.WAV</file>
<file>SOUND49.WAV</file>
<file>SOUND49D.WAV</file>
</dir>
<dir name="Source">
<dir name="Include">
<file>OLEACC.H</file>
<file>OLEAUTO.H</file>
<file>OLECTL.H</file>
</dir>
<file>ATL.CPP</file>
<file>REGOBJ.CPP</file>
<file>STDAFX.CPP</file>
</dir>
<dir name="Spreadsheets">
<file>SAMPLES.XLS</file>
</dir>
<file>bullet.gif</file>
<file>chilkatLicense.txt</file>
<file>default.asp</file>
<file>file.gif</file>
<file>global.asa</file>
<file>guestbk.asp</file>
<file>il941.pdf</file>
<file>myfiles.asp</file>
<file>signbook.asp</file>
<file>sub.inc</file>
<file>theme.inc</file>
<file>themes.inc</file>
</zip_contents>
|
TOP
|
AES
Encryption for Zip Data Compression
|
(Property)
Encryption
As Long read/write
Sets the encryption algorithm. Valid values are: 0 = none,
1 = blowfish, 2 = twofish, 3 = rijndael (AES). When a ZIP
is encrypted, the directory will still be readable by programs
such as WinZip, but the contents, if unzipped, will be garbled.
Only applications using Chilkat Zip can decrypt and unzip
ZIP files created by ChilkatZip.
TOP
(Property)
EncryptKeyLength
As Long read/write
Sets the encryption key length. This value must be 128,
192, or 256.
TOP
(Method)
SetPassword(password
As String)
Sets the password used for encryption or decryption. When
decrypting, the password, algorithm, and key length all
must match the values used during encryption.
TOP
(Method)
GetPassword(password
As String)
Gets the password previously set by SetPassword.
TOP
|
Embedding
a ZIP into an EXE (or accessing a ZIP embedded
within an EXE)
*The ChilkatZip
Self-Extractor program creates self-extracting executables
where the ZIP is embedded in an EXE as a resource having the name
"zip". If you create a self-extracting EXE with this
utility, you can access the embedded ZIP using the methods below.
|
(Method)
AddEmbedded(ExeFileName
As String, ResourceName As String, ZipFileName As String)
Embeds a ZIP file into an EXE. The ZIP is stored as a named
resource within the EXE. You may store more than one ZIP
within a single EXE, so long as the resource names are unique.
TOP
(Method)
ReplaceEmbedded(ExeFileName
As String, ResourceName As String, ZipFileName As String)
Replaces a ZIP embedded in an EXE with another one.
TOP
(Method)
RemoveEmbedded(ExeFileName
As String, ResourceName As String)
Removes an embedded ZIP from an EXE.
TOP
(Method)
OpenEmbedded(ExeFileName
As String, ResourceName As String)
Opens a ZIP embedded within an EXE.
TOP
(Method)
OpenMyEmbedded(ResourceName
As String)
Opens a ZIP embedded within the caller's EXE.
TOP
|
Writing
a Self-Extracting EXE (New in v9.4.0)
|
(Property)
AutoRun
As String read/write
This is the name of a file within the Zip that is designated
to be automatically run after a self-extracting EXE unzips.
If set, then WriteExe will create a self-extracting
EXE that automatically runs this EXE after unzipping. The
typical use for this is to set AutoRun = "Setup.exe"
for installation EXEs. TOP
(Propery)
AutoTemp
As
Long read/write
If True (1) then the EXE created by WriteExe will automatically
unzip to a temp directory when double-clicked. This option
is only valid when an AutoRun filename is also set. If set
to False (0), the self-extracting EXE will prompt for an
unzip directory.
TOP
(Method)
WriteExe(ExeFileName
As String) As Long
Creates a self-extracting EXE and returns 1 if successful,
otherwise returns 0. This is the only method where the supporting
Zip2Exe.DLL must be installed and registered. This DLL is
provided in the Chilkat Zip download.
If the Encryption
property is non-zero, the self-extracting EXE will be AES
encrypted using Rijndael CBC encryption, and the key length
will be set according to the EncryptKeyLength property.
TOP
|
ChilkatZipEntry
Properties
|
(Property)
Comment
As String
read/write
The comment associated with this entry and stored withing
the Zip file.
TOP
(Property)
CompressedLength
As Long read/write
The number of bytes when compressed.
TOP
(Property)
CompressionLevel
As Long read/write
The compression level. 0 = no compression, while 9 = maximum
compression. The default is 6.
TOP
(Property)
CompressionMethod
As Long read/write
Set to 0 for no compression, or 8 for the Deflate algorithm.
The Deflate algorithm is the default algorithm of the most
popular Zip utility programs.
TOP
(Property)
EntryID
As Long read-only
The unique ID assigned by Chilkat Zip while the object is
instantiated in memory.
TOP
(Property)
EntryType
As Long read-only
Indicates the origin of the entry. There are three possible
values: (0) a file on disk, (1) a entry in an existing memory-mapped
Zip file, and (2) an entry created directly from data in
memory.
TOP
(Property)
FileDateTime
As Date read/write
The last-modified time of the entry.
TOP
(Property)
FileName
As String read/write
The entry's filename (or directory path for directory entries).
TOP
(Property)
IsDirectory
As Long
read-only
1 if the entry is a directory, otherwise 0.
TOP
(Property)
UncompressedLength
As Long
read-only
The length in bytes of the uncompressed data.
TOP
(Property)
ZipFile
As ChilkatZip
read-write
A reference to the Zip object that contains this entry.
You can move a Zip entry to another Zip file simply by setting
this property.
TOP
|
Access
to Zip Uncompressed Data
|
(Method)
Inflate(void)
As Variant
Returns the uncompressed data as a Variant.
TOP
(Method)
InflateToString(KeepCR
As Long) As String
Returns the uncompressed data as a string. Line-endings
are modified to include or not include carriage-returns
based on KeepCR. If KeepCR = 0, then bare linefeeds are
returned, otherwise CRLFs are returned.
TOP
(Method)
InflateToString2(void)
As String
Inflates to a string, but leaves the line endings alone.
TOP
|
Access
to Zip Compressed Data
|
(Method)
Copy(void)
As Variant
Returns the compressed data in a Variant.
TOP
(Method)
CopyToBase64(void)
As String
Returns the compressed data as a Base64-encoded string.
This data can be re-added to a Zip by calling ChilkatZip.AppendBase64.
TOP
(Method)
CopyToHex(void)
As String
Returns the compressed data as a hexidecimal encoded string.
This data can be re-added to a Zip by calling ChilkatZip.AppendHex.
TOP
|
Replacing
or Appending Data
|
(Method)
AppendData(Data
As Variant)
Appends data to the existing data in the entry.
TOP
(Method)
ReplaceData(Data
As Variant)
Replaces the entry's data.
TOP
|
Unzipping
|
(Method)
Extract(BaseDirectoryPath
As String)
Unzips this entry into the specified base directory. The
file is unzipped to the subdirectory according to the relative
path stored with the entry in the Zip.
TOP
(Method)
ExtractInto(DirectoryPath
As String)
Unzips this entry into the specified directory, regardless
of the relative directory of the entry.
TOP
|
ChilkatEnum
Iterating
over the Entries in a Zip File
|
(Method)
HasMoreElements(void)
As Long
Returns 1 if the enumeration has more elements, otherwise
returns 0.
TOP
(Method)
NextElement(void)
As IUnknown
Returns the next entry in the enumeration.
TOP
(Method)
NextZipEntry(void)
As ChilkatZipEntry
Returns the next entry in the Zip. Directory entries are
skipped.
TOP
|
|