از TZCompressionStream و TZDecompressionStream استفاده کن
procedure TForm1.btnCompressClick(Sender: TObject);
var
LInput, LOutput: TFileStream;
LZip: TZCompressionStream;
begin
{ Create the Input, Output, and Compressed streams. }
LInput := TFileStream.Create(Edit1.Text, fmOpenRead);
LOutput := TFileStream.Create(Edit2.Text + '.zip', fmCreate);
LZip := TZCompressionStream.Create(clDefault, LOutput);
{ Compress data. }
LZip.CopyFrom(LInput, LInput.Size);
{ Free the streams. }
LZip.Free;
LInput.Free;
LOutput.Free;
end;
procedure TForm1.btnDecompressClick(Sender: TObject);
var
LInput, LOutput: TFileStream;
LUnZip: TZDecompressionStream;
begin
{ Create the Input, Output, and Decompressed streams. }
LInput := TFileStream.Create(Edit1.Text, fmOpenRead);
LOutput := TFileStream.Create(ChangeFileExt(Edit1.Text, 'txt'), fmCreate);
LUnZip := TZDecompressionStream.Create(LInput);
{ Decompress data. }
LOutput.CopyFrom(LUnZip, 0);
{ Free the streams. }
LUnZip.Free;
LInput.Free;
LOutput.Free;
end;