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

Unzip Text File to String

See more Zip Examples

Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.

Chilkat Rust Downloads

Rust

// This example requires 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/EC16100.zip").is_err() {
    println!("{}", zip.last_error_text());
    return;
}

// Get the 1st file in the .zip
let entry = chilkat::ZipEntry::new();
if zip.entry_at(0, &entry).is_err() {
    println!("{}", zip.last_error_text());
    return;
}

let file_contents = entry.unzip_to_string(0, "utf-8").unwrap_or_default();
println!("{}", file_contents);