Visual FoxPro
Visual FoxPro
Zip Append StringBuilder
See more Zip Examples
Append the contents of a Chilkat StringBuilder object to a .zip.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loZip
LOCAL lcZipPath
LOCAL loSb
LOCAL i
LOCAL loZip2
LOCAL lcZipPath2
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loZip = CreateObject('Chilkat.Zip')
lcZipPath = "c:/temp/qa_output/out.zip"
loZip.NewZip(lcZipPath)
loSb = CreateObject('Chilkat.StringBuilder')
i = 0
DO WHILE i < 100
loSb.AppendLine("This is a test",1)
i = i + 1
ENDDO
loZip.AddSb("this_is_a_test.txt",loSb,"utf-8")
lnSuccess = loZip.WriteZipAndClose()
IF (lnSuccess = 0) THEN
? loZip.LastErrorText
RELEASE loZip
RELEASE loSb
CANCEL
ENDIF
? "Success 1."
* Perhaps you want to add a file to an existing .zip
loZip2 = CreateObject('Chilkat.Zip')
* Open the .zip we just wrote..
lnSuccess = loZip2.OpenZip(lcZipPath)
loSb.Clear()
i = 0
DO WHILE i < 100
loSb.AppendLine("This is a test 2",1)
i = i + 1
ENDDO
loZip2.AddSb("this_is_a_test_2.txt",loSb,"utf-8")
lcZipPath2 = "c:/temp/qa_output/out2.zip"
loZip2.FileName = lcZipPath2
lnSuccess = loZip2.WriteZipAndClose()
IF (lnSuccess = 0) THEN
? loZip2.LastErrorText
RELEASE loZip
RELEASE loSb
RELEASE loZip2
CANCEL
ENDIF
? "Success 2."
RELEASE loZip
RELEASE loSb
RELEASE loZip2