Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loZip
LOCAL lnNumEntries
LOCAL loEntry
LOCAL i
LOCAL loFileData

lnSuccess = 0

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

loZip = CreateObject('Chilkat.Zip')

lnSuccess = loZip.OpenZip("qa_data/zips/test.zip")
IF (lnSuccess = 0) THEN
    ? loZip.LastErrorText
    RELEASE loZip
    CANCEL
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('Chilkat.ZipEntry')
i = 0
DO WHILE i < lnNumEntries
    loZip.EntryAt(i,loEntry)
    IF (loEntry.IsDirectory = 0) THEN
        loFileData = loEntry.Inflate()
        * Do whatever you wish with the file data...
    ENDIF

    i = i + 1
ENDDO

loZip.CloseZip()

? "Finished."

RELEASE loZip
RELEASE loEntry