C++
C++
Unzip Text File to String
See more Zip Examples
Demonstrates how to open a .zip and extract the 1st file (assuming it's a text file) to a string variable.Chilkat C++ Downloads
#include <CkZip.h>
#include <CkZipEntry.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkZip zip;
success = zip.OpenZip("qa_data/zips/EC16100.zip");
if (success == false) {
std::cout << zip.lastErrorText() << "\r\n";
return;
}
// Get the 1st file in the .zip
CkZipEntry entry;
success = zip.EntryAt(0,entry);
if (success == false) {
std::cout << zip.lastErrorText() << "\r\n";
return;
}
const char *fileContents = entry.unzipToString(0,"utf-8");
std::cout << fileContents << "\r\n";
}