PowerBuilder
PowerBuilder
Append String as a File to a Zip
See more Zip Examples
Demonstrates how to append text data as a file within a zip archive.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Zip
string ls_ZipPath
string ls_FileContent
string ls_PathInZip
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)
// Append a file that will contain the string "Hello World";
ls_FileContent = "Hello World"
ls_PathInZip = "txtFiles/helloWorld.txt"
loo_Zip.AddString(ls_PathInZip,ls_FileContent,"utf-8")
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