(Lianja) Append String as a File to a Zip
Demonstrates how to append text data as a file within a zip archive.Note: This example requires Chilkat v11.0.0 or greater.
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
|