(Visual FoxPro) 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.
LOCAL lnSuccess
LOCAL loZip
LOCAL lcZipPath
LOCAL lcFileContent
LOCAL lcPathInZip
lnSuccess = 0
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loZip = CreateObject('Chilkat.Zip')
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
lnSuccess = loZip.WriteZipAndClose()
IF (lnSuccess = 0) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
ENDIF
? "Success."
RELEASE loZip
|