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

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

Rust

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

let zip = chilkat::Zip::new();

if zip.open_zip("qa_data/zips/xml_files.zip").is_err() {
    println!("{}", zip.last_error_text());
    return;
}

let entry = chilkat::ZipEntry::new();
let mut has_more_entries = zip.entry_at(0, &entry).is_ok();
while has_more_entries {
    if !entry.is_directory() {
        println!("{}", entry.file_name());
    } else {
        println!("(directory) {}", entry.file_name());
    }

    has_more_entries = entry.get_next().is_ok();
}

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