Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loZip
LOCAL loEntry
LOCAL lnEntryId
LOCAL loEntry2
lnSuccess = 0
lnSuccess = 0
* Open an existing ZIP archive.
loZip = CreateObject('Chilkat.Zip')
lnSuccess = loZip.OpenZip("example.zip")
IF (lnSuccess = 0) THEN
? loZip.LastErrorText
RELEASE loZip
CANCEL
ENDIF
* Retrieve the first entry in the ZIP archive.
loEntry = CreateObject('Chilkat.ZipEntry')
lnSuccess = loZip.EntryAt(0,loEntry)
IF (lnSuccess = 0) THEN
? loZip.LastErrorText
RELEASE loZip
RELEASE loEntry
CANCEL
ENDIF
? "Original entry:"
? " FileName: " + loEntry.FileName
? " EntryID: " + STR(loEntry.EntryID)
? ""
* Save the EntryID for later use.
lnEntryId = loEntry.EntryID
* Create another ZipEntry object.
loEntry2 = CreateObject('Chilkat.ZipEntry')
* Retrieve the same entry using EntryById.
lnSuccess = loZip.EntryById(lnEntryId,loEntry2)
IF (lnSuccess = 0) THEN
? loZip.LastErrorText
RELEASE loZip
RELEASE loEntry
RELEASE loEntry2
CANCEL
ENDIF
? "Entry retrieved by EntryID:"
? " FileName: " + loEntry2.FileName
? " EntryID: " + STR(loEntry2.EntryID)
? ""
* The filenames and EntryID values should match.
loZip.CloseZip()
? "Done."
RELEASE loZip
RELEASE loEntry
RELEASE loEntry2