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

The following code uses the Unzip method to unzip the file "readme.txt" from the zip file "c:\test\my test.zip" into the directory "c:\test\unzipped files". If the directory does not already exist, it will be created automatically. You should check the Unzip 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 list to find out what went wrong. This code assumes you have a button and an Xceed Zip control on a form, named 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 four below } 
      XceedZip1.FilesToProcess := 'readme.txt'; { The file to unzip } 
      XceedZip1.PreservePaths := False;  

      { In case file is stored in the zip file with a path, we need to make }
      {sure the path is removed so that the file will match with 'readme.txt' } 

      XceedZip1.UnzipToFolder := 'c:\test\unzipped files'; 
      XceedZip1.ZipFilename := 'c:\test\my test.zip';  

      { Start unzipping } 
      ResultCode := XceedZip1.Unzip;  

      { Check the return value. If ResultCode = xerSuccess, it worked } 

   end;