AutoIt
AutoIt
Find a ZIP Entry by EntryID Using EntryById
See more Zip Examples
This example demonstrates how to use the EntryById method to retrieve a ZIP entry using its unique EntryID.
Each ZipEntry object has an EntryID property that uniquely identifies the entry within the currently open ZIP object.
This is useful when:
- An application stores EntryID values for later use
- ZIP entries need to be retrieved without searching by filename
- Multiple entries may have similar names or paths
The example:
- Opens a ZIP archive
-
Retrieves an entry using
EntryAt -
Saves the entry's
EntryID -
Uses
EntryByIdto retrieve the same entry later
Chilkat AutoIt Downloads
Local $bSuccess = False
$bSuccess = False
; Open an existing ZIP archive.
$oZip = ObjCreate("Chilkat.Zip")
$bSuccess = $oZip.OpenZip("example.zip")
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
; Retrieve the first entry in the ZIP archive.
$oEntry = ObjCreate("Chilkat.ZipEntry")
$bSuccess = $oZip.EntryAt(0,$oEntry)
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Original entry:" & @CRLF)
ConsoleWrite(" FileName: " & $oEntry.FileName & @CRLF)
ConsoleWrite(" EntryID: " & $oEntry.EntryID & @CRLF)
ConsoleWrite("" & @CRLF)
; Save the EntryID for later use.
Local $iEntryId = $oEntry.EntryID
; Create another ZipEntry object.
$oEntry2 = ObjCreate("Chilkat.ZipEntry")
; Retrieve the same entry using EntryById.
$bSuccess = $oZip.EntryById($iEntryId,$oEntry2)
If ($bSuccess = False) Then
ConsoleWrite($oZip.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Entry retrieved by EntryID:" & @CRLF)
ConsoleWrite(" FileName: " & $oEntry2.FileName & @CRLF)
ConsoleWrite(" EntryID: " & $oEntry2.EntryID & @CRLF)
ConsoleWrite("" & @CRLF)
; The filenames and EntryID values should match.
$oZip.CloseZip
ConsoleWrite("Done." & @CRLF)