PureBasic
PureBasic
Zip a Directory Tree
See more Zip Examples
Demonstrates how to zip an entire directory tree into a .zip archive.Chilkat PureBasic Downloads
IncludeFile "CkZip.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::ckNewZip(zip,"test.zip")
If success <> 1
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
; Append a directory tree. The call to AppendFiles does
; not read the file contents or append them to the zip
; object in memory. It simply appends references
; to the files so that when WriteZip or WriteZipAndClose
; is called, the referenced files are streamed and compressed
; into the .zip output file.
recurse.i = 1
success = CkZip::ckAppendFiles(zip,"c:/temp/a/*",recurse)
If success <> 1
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
success = CkZip::ckWriteZipAndClose(zip)
If success <> 1
Debug CkZip::ckLastErrorText(zip)
CkZip::ckDispose(zip)
ProcedureReturn
EndIf
Debug "Zip Created!"
CkZip::ckDispose(zip)
ProcedureReturn
EndProcedure