![]() |
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. Note: This example requires Chilkat v11.0.0 or greater.
#include <CkCrypt2W.h> #include <CkZipW.h> #include <CkBinDataW.h> #include <CkByteData.h> #include <CkFileAccessW.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. CkCrypt2W crypt; CkZipW zip; success = zip.NewZip(L"test.zip"); if (success == false) { wprintf(L"%s\n",zip.lastErrorText()); return; } // Add the bytes 0x00 0x01 0x02 0x03 ... 0x0F as a file in the .zip CkBinDataW bd; bd.AppendEncoded(L"000102030405060708090A0B0C0D0E0F",L"hex"); zip.AddBd(L"binaryData.dat",bd); // Add the string "Hello World!" to the .zip zip.AddString(L"helloWorld.txt",L"Hello World!",L"utf-8"); 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 == false) { wprintf(L"%s\n",fac.lastErrorText()); return; } wprintf(L"Zip Created!\n"); } |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.