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

 

Compressing a whole custom stream: Example

 


 

The following example illustrates how to compress and decompress the whole file stream to a memory stream.

 

var

mStream: TMemoryStream;

fStream: TFileStream;

begin

{ create destination memory stream for compressed data }

mStream := TMemoryStream.Create;

{ create source file stream with original data }

fStream := TFileStream.Create('c:\test.txt', fmOpenReadWrite or fmShareDenyNone);

{ compress file stream data to the memory stream }

ECLCompressStream(fStream, mStream, '', bzipNormal);

{ save compressed data to disk }

mStream.SaveToFile('c:\test.ecl');

{ free used streams }

mStream.Free;

fStream.Free;

 

{ create destination memory stream for decompressed data }

mStream := TMemoryStream.Create;

{ create source file stream for compressed data file }

fStream := TFileStream.Create('c:\test.ecl', fmOpenReadWrite or fmShareDenyNone);

{ decompress data from file stream to memory stream }

ECLDecompressStream(fStream, mStream, '');

{ save decompressed data }

mStream.SaveToFile('c:\test_dec.txt');

{ free used streams }

mStream.Free;

fStream.Free;

end;

 

        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Dec 22, 2024