DataFlex
DataFlex
Create Empty File and Directory Entries in a ZIP
See more Zip Examples
This example demonstrates how to use the AddEmpty method to create both empty directory entries and empty file entries within a ZIP archive.
The example creates:
- A truly empty directory named
emptyDir - An empty file named
empty.txtlocated beneath thedocssubdirectory
When the ZIP archive is extracted:
emptyDirwill be created as an empty directory.docs/empty.txtwill be created as an empty file under thedocssubdirectory.
It is not necessary to explicitly create the docs directory beforehand. The directory structure implied by the file path is created automatically when extracting.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoZip
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatZip)) To hoZip
If (Not(IsComObjectCreated(hoZip))) Begin
Send CreateComObject of hoZip
End
Get ComNewZip Of hoZip "emptyEntries.zip" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoZip To sTemp1
Showln sTemp1
Procedure_Return
End
// Add an empty directory entry named "emptyDir".
Get ComAddEmpty Of hoZip True "emptyDir" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoZip To sTemp1
Showln sTemp1
Procedure_Return
End
// Add an empty file entry named "docs/empty.txt".
Get ComAddEmpty Of hoZip False "docs/empty.txt" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoZip To sTemp1
Showln sTemp1
Procedure_Return
End
// Write the ZIP archive to disk and close it.
Get ComWriteZipAndClose Of hoZip To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoZip To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "ZIP archive created successfully."
End_Procedure