Classic ASP
Classic ASP
Zip Append StringBuilder
See more Zip Examples
Append the contents of a Chilkat StringBuilder object to a .zip.Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
set zip = Server.CreateObject("Chilkat.Zip")
zipPath = "c:/temp/qa_output/out.zip"
success = zip.NewZip(zipPath)
set sb = Server.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
Response.Write "<pre>" & Server.HTMLEncode( zip.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Success 1.") & "</pre>"
' Perhaps you want to add a file to an existing .zip
set zip2 = Server.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
Response.Write "<pre>" & Server.HTMLEncode( zip2.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "Success 2.") & "</pre>"
%>
</body>
</html>