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
(DataFlex) 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.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoZip String sZipPath Variant vSb Handle hoSb Integer i Handle hoZip2 String sZipPath2 String sTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatZip)) To hoZip If (Not(IsComObjectCreated(hoZip))) Begin Send CreateComObject of hoZip End Move "c:/temp/qa_output/out.zip" To sZipPath Get ComNewZip Of hoZip sZipPath To iSuccess Get Create (RefClass(cComChilkatStringBuilder)) To hoSb If (Not(IsComObjectCreated(hoSb))) Begin Send CreateComObject of hoSb End Move 0 To i While (i < 100) Get ComAppendLine Of hoSb "This is a test" True To iSuccess Move (i + 1) To i Loop Get pvComObject of hoSb to vSb Get ComAppendSb Of hoZip "this_is_a_test.txt" vSb "utf-8" To iSuccess Get ComWriteZipAndClose Of hoZip To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End Showln "Success 1." // Perhaps you want to add a file to an existing .zip Get Create (RefClass(cComChilkatZip)) To hoZip2 If (Not(IsComObjectCreated(hoZip2))) Begin Send CreateComObject of hoZip2 End // Open the .zip we just wrote.. Get ComOpenZip Of hoZip2 sZipPath To iSuccess Send ComClear To hoSb Move 0 To i While (i < 100) Get ComAppendLine Of hoSb "This is a test 2" True To iSuccess Move (i + 1) To i Loop Get pvComObject of hoSb to vSb Get ComAppendSb Of hoZip2 "this_is_a_test_2.txt" vSb "utf-8" To iSuccess Move "c:/temp/qa_output/out2.zip" To sZipPath2 Set ComFileName Of hoZip2 To sZipPath2 Get ComWriteZipAndClose Of hoZip2 To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoZip2 To sTemp1 Showln sTemp1 Procedure_Return End Showln "Success 2." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.