Xbase++ Requires Chilkat v11.0.0+
Xbase++
Unzip Encrypted Text into a String Variable
See more Zip Examples
Demonstrates how to open an encrypted .zip archive and unzip a text file directly into a string variable.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oZip
LOCAL oEntry
LOCAL nLineEndingBehavior
LOCAL cSrcCharset
LOCAL cStrCsv
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oZip := CreateObject("Chilkat.Zip")
// Set the password required for decrypting.
oZip:DecryptPassword := "myPassword"
nSuccess := oZip:OpenZip("encrypted.zip")
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
RETURN
ENDIF
// Locate the file within the Zip to be unzipped into a string variable:
oEntry := CreateObject("Chilkat.ZipEntry")
nSuccess := oZip:EntryMatching("*.csv", oEntry)
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
oEntry:destroy()
RETURN
ENDIF
// lineEndingBehavior:
// 0 = leave unchanged.
// 1 = convert all to bare LF's
// 2 = convert all to CRLF's
nLineEndingBehavior := 0
cSrcCharset := "utf-8"
cStrCsv := oEntry:UnzipToString(nLineEndingBehavior, cSrcCharset)
? cStrCsv
oZip:destroy()
oEntry:destroy()