Rust Requires Chilkat v11.0.0+
Rust
Find a ZIP Entry by EntryID Using EntryById
See more Zip Examples
This example demonstrates how to use the EntryById method to retrieve a ZIP entry using its unique EntryID.
Each ZipEntry object has an EntryID property that uniquely identifies the entry within the currently open ZIP object.
This is useful when:
- An application stores EntryID values for later use
- ZIP entries need to be retrieved without searching by filename
- Multiple entries may have similar names or paths
The example:
- Opens a ZIP archive
-
Retrieves an entry using
EntryAt -
Saves the entry's
EntryID -
Uses
EntryByIdto retrieve the same entry later
Chilkat Rust Downloads
// Open an existing ZIP archive.
let zip = chilkat::Zip::new();
if zip.open_zip("example.zip").is_err() {
println!("{}", zip.last_error_text());
return;
}
// Retrieve the first entry in the ZIP archive.
let entry = chilkat::ZipEntry::new();
if zip.entry_at(0, &entry).is_err() {
println!("{}", zip.last_error_text());
return;
}
println!("Original entry:");
println!(" FileName: {}", entry.file_name());
println!(" EntryID: {}", entry.entry_id());
println!("");
// Save the EntryID for later use.
let entry_id = entry.entry_id();
// Create another ZipEntry object.
let entry2 = chilkat::ZipEntry::new();
// Retrieve the same entry using EntryById.
if zip.entry_by_id(entry_id, &entry2).is_err() {
println!("{}", zip.last_error_text());
return;
}
println!("Entry retrieved by EntryID:");
println!(" FileName: {}", entry2.file_name());
println!(" EntryID: {}", entry2.entry_id());
println!("");
// The filenames and EntryID values should match.
zip.close_zip();
println!("Done.");