Sample code for 30+ languages & platforms
Tcl

List Files in Zip using EntryAt / GetNext

See more Zip Examples

Demonstrates how to iterate over the files and directories in a zip archive using EntryAt/GetNext.

Chilkat Tcl Downloads

Tcl

load ./chilkat.dll

set success 0

# This example assumes the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

set zip [new_CkZip]

set success [CkZip_OpenZip $zip "qa_data/zips/xml_files.zip"]
if {$success == 0} then {
    puts [CkZip_lastErrorText $zip]
    delete_CkZip $zip
    exit
}

set entry [new_CkZipEntry]

set hasMoreEntries [CkZip_EntryAt $zip 0 $entry]
while {$hasMoreEntries == 1} {
    if {[CkZipEntry_get_IsDirectory $entry] == 0} then {
        puts [CkZipEntry_fileName $entry]
    }     else {
        puts "(directory) [CkZipEntry_fileName $entry]"
    }

    set hasMoreEntries [CkZipEntry_GetNext $entry]
}

# Sample output showing both file and directory entries:

# a1.xml
# b1.xml
# c1.xml
# (directory) dir1/
# dir1/a2.xml
# dir1/c2.xml
# (directory) dir2/
# (directory) dir2/dir3/
# dir2/dir3/c3.xml

delete_CkZip $zip
delete_CkZipEntry $entry