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 and Keep OpenSee more Zip ExamplesZip a directory tree by calling WriteZip instead of WriteZipAndClose. When WriteZip is called, the created zip is automatically opened and the zip object contains references to the compressed zip entries (mapped entries) contained within the .zip.
Use ChilkatAx-win32.pkg Procedure Test Handle hoZip Boolean iSuccess String sZipPath Boolean iRecurse Integer iNumEntries Integer i Variant vEntry Handle hoEntry String sTemp1 Boolean bTemp1 // This example assumes 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/myFiles.zip" To sZipPath // Initialize the zip object, which also sets the FileName property to the path of the zip to be created. Get ComNewZip Of hoZip sZipPath To iSuccess // Append references to files to be zipped. Move True To iRecurse Get ComAppendFiles Of hoZip "c:/temp/files_to_zip/*" iRecurse To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // Write the .zip, but don't close the zip file. // The zip file we just created is automatically opened and the zip object // now contains entries that are contained within the zip. (They are memory-mapped entries) Get ComWriteZip Of hoZip To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End Showln "Successfully created " sZipPath // Let's look at what's in the .zip we just created.. Get ComNumEntries Of hoZip To iNumEntries Move 0 To i While (i < iNumEntries) Get ComGetEntryByIndex Of hoZip i To vEntry If (IsComObject(vEntry)) Begin Get Create (RefClass(cComChilkatZipEntry)) To hoEntry Set pvComObject Of hoEntry To vEntry End Get ComIsDirectory Of hoEntry To bTemp1 If (bTemp1) Begin Get ComFileName Of hoEntry To sTemp1 Showln i ": " sTemp1 " (directory)" End Else Begin Get ComFileName Of hoEntry To sTemp1 Showln i ": " sTemp1 End Send Destroy of hoEntry Move (i + 1) To i Loop // Close the zip file when finished. Send ComCloseZip To hoZip End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.