![]() |
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
(C) Find a ZIP Entry by EntryID Using EntryByIdSee more Zip Examples This example demonstrates how to use the Each This is useful when:
The example:
Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkZip.h> #include <C_CkZipEntry.h> void ChilkatSample(void) { BOOL success; HCkZip zip; HCkZipEntry entry; int entryId; HCkZipEntry entry2; success = FALSE; success = FALSE; // Open an existing ZIP archive. zip = CkZip_Create(); success = CkZip_OpenZip(zip,"example.zip"); if (success == FALSE) { printf("%s\n",CkZip_lastErrorText(zip)); CkZip_Dispose(zip); return; } // Retrieve the first entry in the ZIP archive. entry = CkZipEntry_Create(); success = CkZip_EntryAt(zip,0,entry); if (success == FALSE) { printf("%s\n",CkZip_lastErrorText(zip)); CkZip_Dispose(zip); CkZipEntry_Dispose(entry); return; } printf("Original entry:\n"); printf(" FileName: %s\n",CkZipEntry_fileName(entry)); printf(" EntryID: %d\n",CkZipEntry_getEntryID(entry)); printf("\n"); // Save the EntryID for later use. entryId = CkZipEntry_getEntryID(entry); // Create another ZipEntry object. entry2 = CkZipEntry_Create(); // Retrieve the same entry using EntryById. success = CkZip_EntryById(zip,entryId,entry2); if (success == FALSE) { printf("%s\n",CkZip_lastErrorText(zip)); CkZip_Dispose(zip); CkZipEntry_Dispose(entry); CkZipEntry_Dispose(entry2); return; } printf("Entry retrieved by EntryID:\n"); printf(" FileName: %s\n",CkZipEntry_fileName(entry2)); printf(" EntryID: %d\n",CkZipEntry_getEntryID(entry2)); printf("\n"); // The filenames and EntryID values should match. CkZip_CloseZip(zip); printf("Done.\n"); CkZip_Dispose(zip); CkZipEntry_Dispose(entry); CkZipEntry_Dispose(entry2); } |
||||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.