Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Zip Append StringBuilderSee more Zip ExamplesAppend the contents of a Chilkat StringBuilder object to a .zip. Note: This example requires Chilkat v10.0.0 or later.
IncludeFile "CkZip.pb" IncludeFile "CkStringBuilder.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. success.i zip.i = CkZip::ckCreate() If zip.i = 0 Debug "Failed to create object." ProcedureReturn EndIf zipPath.s = "c:/temp/qa_output/out.zip" CkZip::ckNewZip(zip,zipPath) sb.i = CkStringBuilder::ckCreate() If sb.i = 0 Debug "Failed to create object." ProcedureReturn EndIf i.i = 0 While i < 100 CkStringBuilder::ckAppendLine(sb,"This is a test",1) i = i + 1 Wend CkZip::ckAppendSb(zip,"this_is_a_test.txt",sb,"utf-8") success = CkZip::ckWriteZipAndClose(zip) If success = 0 Debug CkZip::ckLastErrorText(zip) CkZip::ckDispose(zip) CkStringBuilder::ckDispose(sb) ProcedureReturn EndIf Debug "Success 1." ; Perhaps you want to add a file to an existing .zip zip2.i = CkZip::ckCreate() If zip2.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Open the .zip we just wrote.. success = CkZip::ckOpenZip(zip2,zipPath) CkStringBuilder::ckClear(sb) i = 0 While i < 100 CkStringBuilder::ckAppendLine(sb,"This is a test 2",1) i = i + 1 Wend CkZip::ckAppendSb(zip2,"this_is_a_test_2.txt",sb,"utf-8") zipPath2.s = "c:/temp/qa_output/out2.zip" CkZip::setCkFileName(zip2, zipPath2) success = CkZip::ckWriteZipAndClose(zip2) If success = 0 Debug CkZip::ckLastErrorText(zip2) CkZip::ckDispose(zip) CkStringBuilder::ckDispose(sb) CkZip::ckDispose(zip2) ProcedureReturn EndIf Debug "Success 2." CkZip::ckDispose(zip) CkStringBuilder::ckDispose(sb) CkZip::ckDispose(zip2) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.