Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
/img/help/home.gif /img/help/prev.gif /img/help/next.gif

 

Creating compressed memory stream

 


 

With Easy Compression Library you could easily compress and encrypt data in memory using a stream interface.

To create an instance of TECLMemoryStream you should call TECLMemoryStream.Create with two optional parameters: Password and CompressionLevel.

When the Password parameter is not blank, it is used to encrypt the file (except the case when CompressionLevel is eclNone).

CompressionLevel indicates the algorithm and mode that is used for compression.

When CompressionLevel is eclNone, TECLMemoryStream is equal to TMemoryStream.

The following example illustrates how to encrypted and compress test.txt in memory and save the compressed data to disk.

Example:

var

CompMS: TECLMemoryStream;

begin

{ create encrypted and compressed memory stream }

CompMS := TECLMemoryStream.Create('Password', bzipMax);

{ load, compress and encrypt test.txt }

CompMS.LoadFromFile('c:\test.txt');

{ use CompMS.CompressedDataStream to access compressed data }

ShowMessage('The size of compressed data is: ' + IntToStr(CompMS.CompressedDataStream.Size));

{ save compressed data to test.ecl }

CompMS.CompressedDataStream.SaveToFile('c:\test.ecl');

{ close destination file }

CompMS.Free;

end;

 

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 21, 2024