Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Zip a Directory Tree with Progress MonitoringDelphi zip compression example program demonstrating how to zip an entire directory tree with progress monitoring and abort capability. // Create a Zip with progress monitoring event callbacks. // The ChilkatZip21 variable is an instance of the Chilkat Zip ActiveX // dropped onto the Delphi form. procedure TForm1.Button1Click(Sender: TObject); var recurse: Integer; success: Integer; begin // UnlockComponent should be called once at the beginning of a program. ChilkatZip21.UnlockComponent('anything for 30-day trial'); // Initialize the zip object. ChilkatZip21.NewZip('test.zip'); // Add a directory tree to the zip object. The AppendFiles // method recursively descends a directory and adds references to // files and directories to the zip object. When the // zip is written (by calling WriteZipAndClose) all referenced files // and directories are added. recurse := 1; ChilkatZip21.AppendFiles('c:/temp/abc/*', recurse); { The directory tree on disk looks like this: C:\temp\abc\dudeA.gif C:\temp\abc\setup.exe C:\temp\abc\b\ C:\temp\abc\b\dudeAbc.gif C:\temp\abc\b\dudeXyz.gif C:\temp\abc\b\Setup.exe C:\temp\abc\b\123\ C:\temp\abc\b\123\dude123.gif C:\temp\abc\b\123\test.txt The directory tree in the .zip looks like this: dudeA.gif setup.exe b\ b\dudeAbc.gif b\dudeXyz.gif b\Setup.exe b\123\ b\123\dude123.gif b\123\test.txt } success := ChilkatZip21.WriteZipAndClose(); if (success = 0) then begin ChilkatZip21.SaveLastError('zipErrorLog.txt'); ShowMessage(ChilkatZip21.LastErrorText); end; ShowMessage('Done!'); end; // This method is called when the percent-done value updates during zipping. // The zip can be aborted by setting the abort argument equal to 1. procedure TForm1.ChilkatZip21WriteZipPercentDone(ASender: TObject; percentDone: Integer; out abort: Integer); begin // percentDone holds a value from 1 to 100. ProgressBar1.Position := percentDone; // Uncomment the following lines to abort the zip after it // is 65% complete. //if (percentDone >= 65) then // abort := 1; end;
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.