(Visual FoxPro) Unzip Text File to String
Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.
LOCAL loZip
LOCAL lnSuccess
LOCAL loEntry
LOCAL lcFileContents
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Zip')
loZip = CreateObject('Chilkat.Zip')
lnSuccess = loZip.OpenZip("qa_data/zips/EC16100.zip")
IF (lnSuccess <> 1) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
ENDIF
* Get the 1st file in the .zip
loEntry = loZip.GetEntryByIndex(0)
IF (loZip.LastMethodSuccess <> 1) THEN
? "No files in this zip."
RELEASE loZip
CANCEL
ENDIF
lcFileContents = loEntry.UnzipToString(0,"utf-8")
? lcFileContents
RELEASE loEntry
RELEASE loZip
|