Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
WriteToMemory / OpenFromMemoryWriting a .zip to memory, opening a .zip from memory.
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; } } |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.