Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

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

loZip = createobject("CkZip")

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

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

// Append a file that will contain the string "Hello World";
lcFileContent = "Hello World"
lcPathInZip = "txtFiles/helloWorld.txt"
loZip.AddString(lcPathInZip,lcFileContent,"utf-8")

loZip.FileName = lcZipPath
llSuccess = loZip.WriteZipAndClose()
if (llSuccess = .F.) then
    ? loZip.LastErrorText
    release loZip
    return
endif

? "Success."


release loZip