Xbase++ Requires Chilkat v11.0.0+
Xbase++
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 Xbase++ Downloads
LOCAL nSuccess
LOCAL oZip
LOCAL oEntry
LOCAL nEntryId
LOCAL oEntry2
nSuccess := 0
// Open an existing ZIP archive.
oZip := CreateObject("Chilkat.Zip")
nSuccess := oZip:OpenZip("example.zip")
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
RETURN
ENDIF
// Retrieve the first entry in the ZIP archive.
oEntry := CreateObject("Chilkat.ZipEntry")
nSuccess := oZip:EntryAt(0, oEntry)
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
oEntry:destroy()
RETURN
ENDIF
? "Original entry:"
? " FileName: " + oEntry:FileName
? " EntryID: " + Str(oEntry:EntryID)
? ""
// Save the EntryID for later use.
nEntryId := oEntry:EntryID
// Create another ZipEntry object.
oEntry2 := CreateObject("Chilkat.ZipEntry")
// Retrieve the same entry using EntryById.
nSuccess := oZip:EntryById(nEntryId, oEntry2)
IF (nSuccess == 0)
? oZip:LastErrorText
oZip:destroy()
oEntry:destroy()
oEntry2:destroy()
RETURN
ENDIF
? "Entry retrieved by EntryID:"
? " FileName: " + oEntry2:FileName
? " EntryID: " + Str(oEntry2:EntryID)
? ""
// The filenames and EntryID values should match.
oZip:CloseZip()
? "Done."
oZip:destroy()
oEntry:destroy()
oEntry2:destroy()