Sample code for 30+ languages & platforms
PowerBuilder

Example for the Zip AppendNewDir Function

See more Zip Examples

Demonstrates the Zip AppendNewDir function.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Zip
string ls_ZipPath
integer li_DirFlag

li_Success = 0

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

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

ls_ZipPath = "c:/temp/test.zip"

// Initialize the zip object, which also sets the FileName property to the path of the zip to be created.
loo_Zip.NewZip(ls_ZipPath)

// AddEmpty is used when you wish to add a directory or empty file to the zip
// such that when the zip is unzipped, the directory will be created
// even if it contains no files.

li_DirFlag = 1

loo_Zip.AddEmpty(li_DirFlag,"dirA")
loo_Zip.AddEmpty(li_DirFlag,"dirB")
loo_Zip.AddEmpty(li_DirFlag,"dirC")

// Write the zip, which contains 3 empty directories: dirA, dirB, dirC.
loo_Zip.FileName = ls_ZipPath
li_Success = loo_Zip.WriteZipAndClose()
if li_Success = 0 then
    Write-Debug loo_Zip.LastErrorText
    destroy loo_Zip
    return
end if

Write-Debug "Success."


destroy loo_Zip