![]() |
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
(PowerBuilder) 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.
integer li_rc integer li_Success oleobject loo_Crypt oleobject loo_Zip oleobject loo_Bd oleobject loo_Fac li_Success = 0 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Crypt = create oleobject li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") if li_rc < 0 then destroy loo_Crypt MessageBox("Error","Connecting to COM object failed") return end if loo_Zip = create oleobject li_rc = loo_Zip.ConnectToNewObject("Chilkat.Zip") li_Success = loo_Zip.NewZip("test.zip") if li_Success = 0 then Write-Debug loo_Zip.LastErrorText destroy loo_Crypt destroy loo_Zip return end if // Add the bytes 0x00 0x01 0x02 0x03 ... 0x0F as a file in the .zip loo_Bd = create oleobject li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData") loo_Bd.AppendEncoded("000102030405060708090A0B0C0D0E0F","hex") loo_Zip.AddBd("binaryData.dat",loo_Bd) // Add the string "Hello World!" to the .zip loo_Zip.AddString("helloWorld.txt","Hello World!","utf-8") loo_ZipFileInMemory = loo_Zip.WriteToMemory() // We could save these files to a file, and it is a valid .zip loo_Fac = create oleobject li_rc = loo_Fac.ConnectToNewObject("Chilkat.FileAccess") li_Success = loo_Fac.WriteEntireFile("test.zip",loo_ZipFileInMemory) if li_Success = 0 then Write-Debug loo_Fac.LastErrorText destroy loo_Crypt destroy loo_Zip destroy loo_Bd destroy loo_Fac return end if Write-Debug "Zip Created!" destroy loo_Crypt destroy loo_Zip destroy loo_Bd destroy loo_Fac |
© 2000-2025 Chilkat Software, Inc. All Rights Reserved.