https://docwiki.embarcadero.com/CodeExamples/Sydney/en/ZLibCompressDecompress_(Delphi)
ZLibCompressDecompress (Delphi) - RAD Studio Code Examples
Description This example shows the usage of TZCompressionStream and TZDecompressionStream. Supply the two filenames in the Edit controls of the main form and then press either the Compress or the Decompress button to do the actions. When the Compress butto
docwiki.embarcadero.com
uses System.ZLib;
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;반응형
'Delphi' 카테고리의 다른 글
| [Delphi] TStopwatch 사용 (0) | 2022.09.02 |
|---|---|
| [Delphi] TNetHttpClient multipart/form-data : Send File (0) | 2022.06.20 |
| [Delphi] Socket 에러에 따른 내용 (0) | 2022.05.17 |
| [Delphi] TreeView Node 에서 마우스 우측버튼 사용시 선택 (0) | 2022.05.17 |
| [Delphi] MS Excel Automation in Delphi (0) | 2022.05.14 |