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

Unzip Files to Byte Array

See more Zip Examples

Demonstrates how to unzip each file contained in a .zip to an in-memory byte array.

Chilkat Lianja Downloads

Lianja
llSuccess = .F.

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

loZip = createobject("CkZip")

llSuccess = loZip.OpenZip("qa_data/zips/test.zip")
if (llSuccess = .F.) then
    ? loZip.LastErrorText
    release loZip
    return
endif

//  Iterate of each entry in the zip.
//  An entry can be a file or directory entry.  For each file, unzip to a byte array.
lnNumEntries = loZip.NumEntries
? "NumEntries = " + str(lnNumEntries)

loEntry = createobject("CkZipEntry")
i = 0
do while i < lnNumEntries
    loZip.EntryAt(i,loEntry)
    if (loEntry.IsDirectory = .F.) then
        loFileData = loEntry.Inflate()
        //  Do whatever you wish with the file data...
    endif

    i = i + 1
enddo

loZip.CloseZip()

? "Finished."


release loZip
release loEntry