Visual FoxPro
Visual FoxPro
Zip a Directory Tree
See more Zip Examples
Demonstrates how to zip an entire directory tree into a .zip archive.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loZip
LOCAL lnRecurse
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loZip = CreateObject('Chilkat.Zip')
lnSuccess = loZip.NewZip("test.zip")
IF (lnSuccess <> 1) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
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.
lnRecurse = 1
lnSuccess = loZip.AppendFiles("c:/temp/a/*",lnRecurse)
IF (lnSuccess <> 1) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
ENDIF
lnSuccess = loZip.WriteZipAndClose()
IF (lnSuccess <> 1) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
ENDIF
? "Zip Created!"
RELEASE loZip