![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java JavaScript Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Iterate Through ZIP Entries Using EntryAt and ZipEntry.GetNextSee more Zip ExamplesThis example demonstrates how to iterate through all entries in a ZIP archive using:
The example prints each ZIP entry's stored filename and whether the entry is a file or directory. This approach is useful when sequentially processing ZIP entries without repeatedly calling Suppose the ZIP archive contains: The example iterates through each entry in the order stored within the ZIP archive.
Use ChilkatAx-win32.pkg Procedure Test Boolean iSuccess Handle hoZip Variant vEntry Handle hoEntry String sTemp1 Integer iTemp1 Boolean bTemp1 Move False To iSuccess Get Create (RefClass(cComChilkatZip)) To hoZip If (Not(IsComObjectCreated(hoZip))) Begin Send CreateComObject of hoZip End // Open an existing ZIP archive. Get ComOpenZip Of hoZip "c:/temp/example.zip" To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // A ZIP archive may contain zero entries. Get ComNumEntries Of hoZip To iTemp1 If (iTemp1 = 0) Begin Showln "The ZIP archive is empty." Send ComCloseZip To hoZip Procedure_Return End // ------------------------------------------------------------ // Get the first ZIP entry. // // EntryAt(0,entry) initializes the ZipEntry object so that // it represents the first entry in the ZIP archive. // Get Create (RefClass(cComChilkatZipEntry)) To hoEntry If (Not(IsComObjectCreated(hoEntry))) Begin Send CreateComObject of hoEntry End Get pvComObject of hoEntry to vEntry Get ComEntryAt Of hoZip 0 vEntry To iSuccess If (iSuccess = False) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // ------------------------------------------------------------ // Iterate through all ZIP entries. // // GetNext updates the same ZipEntry object so that it // represents the next entry in the ZIP archive. // While (iSuccess = True) Get ComIsDirectory Of hoEntry To bTemp1 If (bTemp1 = True) Begin Get ComFileName Of hoEntry To sTemp1 Showln "[Directory] " sTemp1 End Else Begin Get ComFileName Of hoEntry To sTemp1 Showln "[File] " sTemp1 End // Advance to the next entry. Get ComGetNext Of hoEntry To iSuccess Loop Send ComCloseZip To hoZip Showln "Done." End_Procedure |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.