Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

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

loZip = createobject("CkZip")

llSuccess = loZip.OpenZip("qa_data/zips/xml_files.zip")
if (llSuccess = .F.) then
    ? loZip.LastErrorText
    release loZip
    return
endif

loEntry = createobject("CkZipEntry")
llHasMoreEntries = loZip.EntryAt(0,loEntry)
do while (llHasMoreEntries = .T.)
    if (loEntry.IsDirectory = .F.) then
        ? loEntry.FileName
    else
        ? "(directory) " + loEntry.FileName
    endif

    llHasMoreEntries = loEntry.GetNext()
enddo

// 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


release loZip
release loEntry