Lua Requires Chilkat v11.0.0+
Lua
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 Lua Downloads
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("qa_data/zips/EC16100.zip")
if not success then
print(zip.last_error_text)
return
end
-- Get the 1st file in the .zip
local entry = chilkat.ZipEntry.new()
success = zip:entry_at(0, entry)
if not success then
print(zip.last_error_text)
return
end
local fileContents = entry:unzip_to_string(0, "utf-8")
print(fileContents)