Xceed Streaming Compression Library Documentation
Compressing from file to file (Delphi example)
Examples > Compressing from file to file (Delphi example)

Here are two examples for compressing from file to file. One for compression, the other for decompression.

Delphi - Compression Copy Code

uses XceedStreamingCompressionLib_TLB 

var
  xComp : TXceedStreamingCompression; 
  xBZip2 : DXceedBZip2CompressionFormat; 
  vaBytesRead : OleVariant; 
begin
  xComp := TXceedStreamingCompression.Create( self ); 
  xComp.License( 'your license key' ); 

  xBZip2 := CoXceedBZip2CompressionFormat.Create();  

  try 
    xComp.CompressionFormat := xBZip2; 
    xComp.ProcessFile( 'c:\temp\source.txt', 0, 0, cfpCompress, true,
                       'c:\compressed.cmp', false, vaBytesRead );  

    ShowMessage( 'Compression successful!' ); 

    xComp.Free(); 
  except 
    on xErr : Exception do 
      ShowMessage( xErr.Message ); 
  end; 
end;

Delphi - Decompression Copy Code

uses XceedStreamingCompressionLib_TLB 

var
  xComp : TXceedStreamingCompression; 
  xBZip2 : DXceedBZip2CompressionFormat; 
  vaBytesRead : OleVariant; 
begin
  xComp := TXceedStreamingCompression.Create( self ); 
  xComp.License( 'your license key' ); 

  xBZip2 := CoXceedBZip2CompressionFormat.Create(); 
  try 
    xComp.CompressionFormat := xBZip2; 
    xComp.ProcessFile( 'e:\destination.cmp', 0, 0, cfpDecompress, true, 
                       'e:\uncompressed.txt', false, vaBytesRead );  

    ShowMessage( 'Decompression successful!' ); 
    xComp.Free(); 
  except 
    on xErr : Exception do 
      ShowMessage( xErr.Message ); 
  end; 
end;