Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) 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.
Use ChilkatAx-win32.pkg Procedure Test Handle hoCrypt Handle hoZip Boolean iSuccess Variant hoBinFileData Variant vEntry Handle hoEntry Variant hoZipFileInMemory Handle hoFac String sTemp1 // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatCrypt2)) To hoCrypt If (Not(IsComObjectCreated(hoCrypt))) Begin Send CreateComObject of hoCrypt End Get Create (RefClass(cComChilkatZip)) To hoZip If (Not(IsComObjectCreated(hoZip))) Begin Send CreateComObject of hoZip End Get ComNewZip Of hoZip "test.zip" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoZip To sTemp1 Showln sTemp1 Procedure_Return End // Add the bytes 0x00 0x01 0x02 0x03 ... 0x0F as a file in the .zip Get ComDecode Of hoCrypt "000102030405060708090A0B0C0D0E0F" "hex" To hoBinFileData Get ComAppendData Of hoZip "binaryData.dat" vBinFileData To vEntry If (IsComObject(vEntry)) Begin Get Create (RefClass(cComChilkatZipEntry)) To hoEntry Set pvComObject Of hoEntry To vEntry End Send Destroy of hoEntry // Add the string "Hello World!" to the .zip Get ComAppendString2 Of hoZip "helloWorld.txt" "Hello World!" "utf-8" To vEntry If (IsComObject(vEntry)) Begin Get Create (RefClass(cComChilkatZipEntry)) To hoEntry Set pvComObject Of hoEntry To vEntry End Send Destroy of hoEntry Get ComWriteToMemory Of hoZip To hoZipFileInMemory // We could save these files to a file, and it is a valid .zip Get Create (RefClass(cComCkFileAccess)) To hoFac If (Not(IsComObjectCreated(hoFac))) Begin Send CreateComObject of hoFac End Get ComWriteEntireFile Of hoFac "test.zip" vZipFileInMemory To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoFac To sTemp1 Showln sTemp1 Procedure_Return End Showln "Zip Created!" End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.