Sample code for 30+ languages & platforms
JavaScript

List Files in a .zip

See more Zip Examples

How to list files within a .zip
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

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

var zip = new CkZip();

success = zip.OpenZip("a.zip");
if (success == false) {
    console.log(zip.LastErrorText);
    return;
}

// Get the number of files and directories in the .zip
var n = zip.NumEntries;

var entry = new CkZipEntry();

var i = 0;

while (i < n) {
    zip.EntryAt(i,entry);
    if (entry.IsDirectory == false) {
        // (the filename may include a path)
        console.log(entry.FileName);
    }

    i = i+1;
}