Xceed Zip Compression Library Documentation
Zip method example for Delphi
Example topics > Zip method example for Delphi

The following code uses the Zip method to compress the file "c:\test\my file.dat" into the zip file "c:\test\my test.zip". You should check the Zip method's return value once you are done – if it is xerSuccess , the operation was successful. Otherwise, look up the error code in the error codes topic to find out what went wrong. The following code assumes you placed a button and an Xceed Zip control on a form and named them Button1 and XceedZip1 respectively.

Delphi Copy Code

procedure TForm1.Button1Click(Sender: TObject);
var   ResultCode: xcdError;  

   begin

      XceedZip1.License( 'your license key' ); 

      { All properties keep their default values except the two below } 
      XceedZip1.FilesToProcess := 'c:\test\my file.dat'; 
      XceedZip1.ZipFilename := 'c:\test\my test.zip';  

      { Start zipping } 
      ResultCode := XceedZip1.Zip;  

      { Check the return value. If ResultCode = xerSuccess, it worked, 
      otherwise, display a message box that with a description of 
      the error. Use the GetErrorDescription function. }   

   end;