Sample code for 30+ languages & platforms
Visual FoxPro

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

Visual FoxPro
LOCAL lnSuccess
LOCAL loZip
LOCAL loEntry
LOCAL lcFileContents

lnSuccess = 0

* This example requires 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/EC16100.zip")
IF (lnSuccess = 0) THEN
    ? loZip.LastErrorText
    RELEASE loZip
    CANCEL
ENDIF

* Get the 1st file in the .zip
loEntry = CreateObject('Chilkat.ZipEntry')
lnSuccess = loZip.EntryAt(0,loEntry)
IF (lnSuccess = 0) THEN
    ? loZip.LastErrorText
    RELEASE loZip
    RELEASE loEntry
    CANCEL
ENDIF

lcFileContents = loEntry.UnzipToString(0,"utf-8")
? lcFileContents

RELEASE loZip
RELEASE loEntry