Sample code for 30+ languages & platforms
Tcl

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

Tcl

load ./chilkat.dll

set success 0

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

set zip [new_CkZip]

set success [CkZip_OpenZip $zip "qa_data/zips/EC16100.zip"]
if {$success == 0} then {
    puts [CkZip_lastErrorText $zip]
    delete_CkZip $zip
    exit
}

# Get the 1st file in the .zip
set entry [new_CkZipEntry]

set success [CkZip_EntryAt $zip 0 $entry]
if {$success == 0} then {
    puts [CkZip_lastErrorText $zip]
    delete_CkZip $zip
    delete_CkZipEntry $entry
    exit
}

set fileContents [CkZipEntry_unzipToString $entry 0 "utf-8"]
puts "$fileContents"

delete_CkZip $zip
delete_CkZipEntry $entry