DataFlex Requires Chilkat v11.0.0+
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoZip
Integer iNumEntries
Variant vEntry
Handle hoEntry
Integer i
Variant hoFileData
String sTemp1
Boolean bTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatZip)) To hoZip
If (Not(IsComObjectCreated(hoZip))) Begin
Send CreateComObject of hoZip
End
Get ComOpenZip Of hoZip "qa_data/zips/test.zip" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoZip To sTemp1
Showln sTemp1
Procedure_Return
End
// Iterate of each entry in the zip.
// An entry can be a file or directory entry. For each file, unzip to a byte array.
Get ComNumEntries Of hoZip To iNumEntries
Showln "NumEntries = " iNumEntries
Get Create (RefClass(cComChilkatZipEntry)) To hoEntry
If (Not(IsComObjectCreated(hoEntry))) Begin
Send CreateComObject of hoEntry
End
Move 0 To i
While (i < iNumEntries)
Get pvComObject of hoEntry to vEntry
Get ComEntryAt Of hoZip i vEntry To iSuccess
Get ComIsDirectory Of hoEntry To bTemp1
If (bTemp1 = False) Begin
Get ComInflate Of hoEntry To hoFileData
// Do whatever you wish with the file data...
End
Move (i + 1) To i
Loop
Send ComCloseZip To hoZip
Showln "Finished."
End_Procedure