PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Zip
li_Success = 0
loo_Zip = create oleobject
li_rc = loo_Zip.ConnectToNewObject("Chilkat.Zip")
if li_rc < 0 then
destroy loo_Zip
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Zip.NewZip("emptyEntries.zip")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
// Add an empty directory entry named "emptyDir".
li_Success = loo_Zip.AddEmpty(1,"emptyDir")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
// Add an empty file entry named "docs/empty.txt".
li_Success = loo_Zip.AddEmpty(0,"docs/empty.txt")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
// Write the ZIP archive to disk and close it.
li_Success = loo_Zip.WriteZipAndClose()
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
Write-Debug "ZIP archive created successfully."
destroy loo_Zip