Chilkat • HOME • Android™ • AutoIt • C • C# • C++ • Chilkat2-Python • CkPython • Classic ASP • DataFlex • Delphi DLL • Go • Java • 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
(Unicode C++) Create a Zip Entirely in MemoryDemonstrates how to create a .zip from in-memory byte data and strings, and to write the .zip to an in-memory image.
#include <CkCrypt2W.h> #include <CkZipW.h> #include <CkByteData.h> #include <CkZipEntryW.h> #include <CkFileAccessW.h> void ChilkatSample(void) { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkCrypt2W crypt; CkZipW zip; bool success = zip.NewZip(L"test.zip"); if (success != true) { wprintf(L"%s\n",zip.lastErrorText()); return; } // Add the bytes 0x00 0x01 0x02 0x03 ... 0x0F as a file in the .zip CkByteData binFileData; success = crypt.Decode(L"000102030405060708090A0B0C0D0E0F",L"hex",binFileData); CkZipEntryW *entry = zip.AppendData(L"binaryData.dat",binFileData); delete entry; // Add the string "Hello World!" to the .zip entry = zip.AppendString2(L"helloWorld.txt",L"Hello World!",L"utf-8"); delete entry; CkByteData zipFileInMemory; success = zip.WriteToMemory(zipFileInMemory); // We could save these files to a file, and it is a valid .zip CkFileAccessW fac; success = fac.WriteEntireFile(L"test.zip",zipFileInMemory); if (success != true) { wprintf(L"%s\n",fac.lastErrorText()); return; } wprintf(L"Zip Created!\n"); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.