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
WriteToMemory / OpenFromMemoryWriting a .zip to memory, opening a .zip from memory. Downloads: MS Windows Visual C/C++ Libraries Linux/CentOS C/C++ Libraries MAC OS X C/C++ Libraries Solaris C/C++ Libraries C++ Builder Libraries void ChilkatSample(void) { // // Write a zip to memory, open a zip from memory... CkZip zip; bool success; // Any string unlocks the component for the 1st 30-days. success = zip.UnlockComponent("Anything for 30-day trial"); if (success != true) { printf("%s\n",zip.lastErrorText()); return; } // Initialize the zip object: zip.NewZip("unused.zip"); // Append a directory tree: bool recurse = true; success = zip.AppendFiles("c:/temp/abc123/*",recurse); if (success != true) { printf("%s\n",zip.lastErrorText()); return; } // Write an image of the .zip file into memory. // (Normally you might call zip.WriteZipAndClose() to write the zip to the filename // previously specified in the NewZip call.) CkByteData zipInMemory; success = zip.WriteToMemory(zipInMemory); if (success != true) { printf("%s\n",zip.lastErrorText()); return; } // Access the raw bytes of the zip in memory: const unsigned char *zipImage = zipInMemory.getBytes(); unsigned long zipSize = zipInMemory.getSize(); // Save to a .zip file: zipInMemory.saveFile("test.zip"); // Open the .zip directly from memory: CkZip zip2; success = zip2.OpenFromMemory(zipImage,zipSize); if (success != true) { printf("%s\n",zip2.lastErrorText()); return; } // Unzip: int unzipCount = zip2.Unzip("c:/temp/zipTestingDir"); if (unzipCount < 0) { printf("%s\n",zip2.lastErrorText()); return; } } |
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.