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

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 VBScript Downloads

VBScript
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)

success = 0

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

set zip = CreateObject("Chilkat.Zip")

'  Set the password required for decrypting.
zip.DecryptPassword = "myPassword"

success = zip.OpenZip("encrypted.zip")
If (success = 0) Then
    outFile.WriteLine(zip.LastErrorText)
    WScript.Quit
End If

'  Locate the file within the Zip to be unzipped into a string variable:
set entry = CreateObject("Chilkat.ZipEntry")
success = zip.EntryMatching("*.csv",entry)
If (success = 0) Then
    outFile.WriteLine(zip.LastErrorText)
    WScript.Quit
End If

'  lineEndingBehavior:
'  0 = leave unchanged.
'  1 = convert all to bare LF's
'  2 = convert all to CRLF's
lineEndingBehavior = 0
srcCharset = "utf-8"

strCsv = entry.UnzipToString(lineEndingBehavior,srcCharset)
outFile.WriteLine(strCsv)

outFile.Close