Xbase++ Requires Chilkat v11.0.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oZip
LOCAL cZipPath
LOCAL cFileContent
LOCAL cPathInZip
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oZip := CreateObject("Chilkat.Zip")
cZipPath := "c:/temp/test.zip"
// Initialize the zip object, which also sets the FileName property to the path of the zip to be created.
oZip:NewZip(cZipPath)
// Append a file that will contain the string "Hello World";
cFileContent := "Hello World"
cPathInZip := "txtFiles/helloWorld.txt"
oZip:AddString(cPathInZip, cFileContent, "utf-8")
oZip:FileName := cZipPath
nSuccess := oZip:WriteZipAndClose()
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
RETURN
ENDIF
? "Success."
oZip:destroy()