(PureBasic) List Files in a .zip
How to list files within a .zip Note: This example requires Chilkat v11.0.0 or greater.
IncludeFile "CkZip.pb"
IncludeFile "CkZipEntry.pb"
Procedure ChilkatExample()
success.i = 0
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
zip.i = CkZip::ckCreate()
If zip.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success = CkZip::ckOpenZip(zip,"a.zip")
If success = 0
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
; Get the number of files and directories in the .zip
n.i = CkZip::ckNumEntries(zip)
entry.i = CkZipEntry::ckCreate()
If entry.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
i.i = 0
While i < n
CkZip::ckEntryAt(zip,i,entry)
If CkZipEntry::ckIsDirectory(entry) = 0
; (the filename may include a path)
Debug CkZipEntry::ckFileName(entry)
EndIf
i = i + 1
Wend
CkZip::ckDispose(zip)
CkZipEntry::ckDispose(entry)
ProcedureReturn
EndProcedure
|