(Visual FoxPro) Append String as a File to a Zip
Demonstrates how to append text data as a file within a zip archive.
LOCAL loZip
LOCAL lnSuccess
LOCAL lcZipPath
LOCAL lcFileContent
LOCAL lcPathInZip
LOCAL loEntry
* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Zip')
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"
loEntry = loZip.AppendString(lcPathInZip,lcFileContent)
RELEASE loEntry
loZip.FileName = lcZipPath
lnSuccess = loZip.WriteZipAndClose()
IF (lnSuccess = 0) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
ENDIF
? "Success."
RELEASE loZip
|