Xceed Zip for COM/ActiveX on x86/x64 Documentation
Example topics
/ TestZipFile method and TestingFile event example for Delphi
In This Topic
TestZipFile method and TestingFile event example for Delphi
In This Topic
This example demonstrates how to test the integrity of the files contained within the the zip file "c:\Test\zip.zip".
The first function of the following code starts the test. For this example, nothing is specified in the FilesToProcess property, so all files inside the zip file will be tested. In this example we call TestZipFile with the bCheckCompressedData parameter set to True, so that the actual compressed data is checked too, not just the zip file's structure and file headers. The second function below is a handler written for the TestingFile event that displays (in a listbox) the filename of each file being tested, along with some other of the file's information. The third function below is a handler written for the Warning event, that adds detailed information about any encountered errors into the same listbox. The code assumes you have placed a button, a listbox and an Xceed Zip control on a form, and named them Button1, ListBox1 and XceedZip1 respectively.
We start with the handler for the button's click event. The code will start the testing.
Delphi
Copy Code
procedure TForm1.Button1Click(Sender: TObject);
var
ResultCode : xcderror;
begin XceedZip1.License( 'your license key' );
{ Name and path of the zip file to test } Xceedzip1.zipfilename := 'c:\Test\zip.zip';
{ Start testing the file (we use True here so that we also test the actual compressed data, not just the zip file's structure }
ResultCode := Xceedzip1.TestZipFile(True);
{Check the return value}
If ResultCode <> xerSuccess Then ShowMessage('Unsuccessful. Error # ' + IntToStr(ResultCode)) Else ShowMessage('The tested zip file is completely error-free.'); end;
Here's the handler for the TestingFile event. It will add each file's name and info to the listbox.