(Unicode C) List Files in a .zip
How to list files within a .zip
#include <C_CkZipW.h>
#include <C_CkZipEntryW.h>
void ChilkatSample(void)
{
HCkZipW zip;
BOOL success;
int n;
HCkZipEntryW entry;
int i;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
zip = CkZipW_Create();
success = CkZipW_OpenZip(zip,L"a.zip");
if (success != TRUE) {
wprintf(L"%s\n",CkZipW_lastErrorText(zip));
CkZipW_Dispose(zip);
return;
}
// Get the number of files and directories in the .zip
n = CkZipW_getNumEntries(zip);
wprintf(L"%d\n",n);
for (i = 0; i <= n - 1; i++) {
entry = CkZipW_GetEntryByIndex(zip,i);
if (CkZipEntryW_getIsDirectory(entry) == FALSE) {
// (the filename may include a path)
wprintf(L"%s\n",CkZipEntryW_fileName(entry));
}
CkZipEntryW_Dispose(entry);
}
CkZipW_Dispose(zip);
}
|