PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Zip
oleobject loo_Entry
integer li_EntryId
oleobject loo_Entry2
li_Success = 0
li_Success = 0
// Open an existing ZIP archive.
loo_Zip = create oleobject
li_rc = loo_Zip.ConnectToNewObject("Chilkat.Zip")
if li_rc < 0 then
destroy loo_Zip
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_Zip.OpenZip("example.zip")
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
return
end if
// Retrieve the first entry in the ZIP archive.
loo_Entry = create oleobject
li_rc = loo_Entry.ConnectToNewObject("Chilkat.ZipEntry")
li_Success = loo_Zip.EntryAt(0,loo_Entry)
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
destroy loo_Entry
return
end if
Write-Debug "Original entry:"
Write-Debug " FileName: " + loo_Entry.FileName
Write-Debug " EntryID: " + string(loo_Entry.EntryID)
Write-Debug ""
// Save the EntryID for later use.
li_EntryId = loo_Entry.EntryID
// Create another ZipEntry object.
loo_Entry2 = create oleobject
li_rc = loo_Entry2.ConnectToNewObject("Chilkat.ZipEntry")
// Retrieve the same entry using EntryById.
li_Success = loo_Zip.EntryById(li_EntryId,loo_Entry2)
if li_Success = 0 then
Write-Debug loo_Zip.LastErrorText
destroy loo_Zip
destroy loo_Entry
destroy loo_Entry2
return
end if
Write-Debug "Entry retrieved by EntryID:"
Write-Debug " FileName: " + loo_Entry2.FileName
Write-Debug " EntryID: " + string(loo_Entry2.EntryID)
Write-Debug ""
// The filenames and EntryID values should match.
loo_Zip.CloseZip()
Write-Debug "Done."
destroy loo_Zip
destroy loo_Entry
destroy loo_Entry2