VBScript
VBScript
Zip Append StringBuilder
See more Zip Examples
Append the contents of a Chilkat StringBuilder object to a .zip.Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set zip = CreateObject("Chilkat.Zip")
zipPath = "c:/temp/qa_output/out.zip"
success = zip.NewZip(zipPath)
set sb = CreateObject("Chilkat.StringBuilder")
i = 0
Do While i < 100
success = sb.AppendLine("This is a test",1)
i = i + 1
Loop
success = zip.AddSb("this_is_a_test.txt",sb,"utf-8")
success = zip.WriteZipAndClose()
If (success = 0) Then
outFile.WriteLine(zip.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Success 1.")
' Perhaps you want to add a file to an existing .zip
set zip2 = CreateObject("Chilkat.Zip")
' Open the .zip we just wrote..
success = zip2.OpenZip(zipPath)
sb.Clear
i = 0
Do While i < 100
success = sb.AppendLine("This is a test 2",1)
i = i + 1
Loop
success = zip2.AddSb("this_is_a_test_2.txt",sb,"utf-8")
zipPath2 = "c:/temp/qa_output/out2.zip"
zip2.FileName = zipPath2
success = zip2.WriteZipAndClose()
If (success = 0) Then
outFile.WriteLine(zip2.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Success 2.")
outFile.Close