Sample code for 30+ languages & platforms
Lua Requires Chilkat v11.0.0+

List Files in a .zip

See more Zip Examples

How to list files within a .zip

Chilkat Lua Downloads

Lua
local chilkat = require("chilkat")

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

local zip = chilkat.Zip.new()

local success = zip:open_zip("a.zip")
if not success then
    print(zip.last_error_text)
    return
end

-- Get the number of files and directories in the .zip
local n = zip.num_entries

local entry = chilkat.ZipEntry.new()

local i = 0

while i < n do
    zip:entry_at(i, entry)
    if not entry.is_directory then
        -- (the filename may include a path)
        print(entry.file_name)
    end

    i = i + 1
end