Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Create a Zip from Data in MemoryDownloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries Demonstrates how to create a Zip from in-memory data. // Visual C++ Zip Compression Example Source Code // to create a Zip file from data in memory. // #include "stdafx.h" #include <CkZip.h> #include <CkZipEntry.h> #include <CkString.h> int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // Unlock the Zip product. // This only needs to be done once when the first CkZip object // is instantiated. CkZip zip; zip.UnlockComponent("unlockCode"); // Initialize a new Zip object. zip.NewZip("myZip.zip"); // Generate some text to be stored in the Zip. CkString s; int i; for (i=0; i<100; i++) { s.append("This data will be stored in a Zip file.\r\n"); } // Append the data to the Zip object. // The entry object is returned and should be deleted by the application. CkZipEntry *entry = zip.AppendData("stringData.txt",(const unsigned char *)s.getString(),s.getNumChars()); delete entry; zip.WriteZipAndClose(0); // Now let's re-open the Zip, modify the data, and rewrite the Zip. // Open the Zip. CkZip zip2; zip2.OpenZip("myZip.zip"); // Get the data. CkZipEntry *entry2 = zip2.FirstEntry(); CkString s2; entry2->InflateToString2(s2); // Replace all occurances of the string "data" with "text" s2.replaceAllOccurances("data","text"); // Replace this Zip entry's data. entry2->ReplaceData(s2); delete entry2; // Save the Zip. zip2.WriteZipAndClose(0); return 0; }
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.