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
(Delphi DLL) Zip Append StringBuilderSee more Zip ExamplesAppend the contents of a Chilkat StringBuilder object to a .zip. Note: This example requires Chilkat v10.0.0 or later.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Zip, StringBuilder; ... procedure TForm1.Button1Click(Sender: TObject); var success: Boolean; zip: HCkZip; zipPath: PWideChar; sb: HCkStringBuilder; i: Integer; zip2: HCkZip; zipPath2: PWideChar; begin // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. zip := CkZip_Create(); zipPath := 'c:/temp/qa_output/out.zip'; CkZip_NewZip(zip,zipPath); sb := CkStringBuilder_Create(); i := 0; while i < 100 do begin CkStringBuilder_AppendLine(sb,'This is a test',True); i := i + 1; end; CkZip_AppendSb(zip,'this_is_a_test.txt',sb,'utf-8'); success := CkZip_WriteZipAndClose(zip); if (success = False) then begin Memo1.Lines.Add(CkZip__lastErrorText(zip)); Exit; end; Memo1.Lines.Add('Success 1.'); // Perhaps you want to add a file to an existing .zip zip2 := CkZip_Create(); // Open the .zip we just wrote.. success := CkZip_OpenZip(zip2,zipPath); CkStringBuilder_Clear(sb); i := 0; while i < 100 do begin CkStringBuilder_AppendLine(sb,'This is a test 2',True); i := i + 1; end; CkZip_AppendSb(zip2,'this_is_a_test_2.txt',sb,'utf-8'); zipPath2 := 'c:/temp/qa_output/out2.zip'; CkZip_putFileName(zip2,zipPath2); success := CkZip_WriteZipAndClose(zip2); if (success = False) then begin Memo1.Lines.Add(CkZip__lastErrorText(zip2)); Exit; end; Memo1.Lines.Add('Success 2.'); CkZip_Dispose(zip); CkStringBuilder_Dispose(sb); CkZip_Dispose(zip2); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.