procedure Compress(InputFileName, OutputFileName:
string);
var InputStream, OutputStream: TFileStream;
CompressionStream:
ZLib.TCompressionStream;
begin
inputstream := Tfilestream.Create(InputFileName, fmOpenRead);
try
OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
try
CompressionStream:=TCompressionStream.Create(clMax, OutputStream);
try
CompressionStream.CopyFrom(InputStream, InputStream.Size);
finally
CompressionStream.Free;
end;
finally
OutputStream.Free;
end;
finally
InputStream.Free;
end;
end;
procedure Decompress(InputFileName, OutputFileName:
string);
var InputStream, OutputStream: TFileStream;
DeCompressionStream:
ZLib.TDeCompressionStream;
Buf:
array[0..4095]
of Byte;
Count: Integer;
begin
InputStream:=TFileStream.Create(InputFileName, fmOpenRead);
try
OutputStream:=TFileStream.Create(OutputFileName, fmCreate);
try
DecompressionStream := TDecompressionStream.Create(InputStream);
try
while true
do
begin
Count := DecompressionStream.
Read(Buf[0], SizeOf(Buf));
if Count = 0
then
break
else
OutputStream.
Write(Buf[0], Count);
end;
finally
DecompressionStream.Free;
end;
finally
OutputStream.Free;
end;
finally
InputStream.Free;
end;
end;
// erst mal nur packen
procedure TForm1.sButton1Click(Sender: TObject);
begin
savedialog1.Execute;
speicher := savedialog1.FileName;
Compress(pfadn,speicher+'
.zip');
// pfadn = die Dateien in der Listbox , Speicher = der Speicherort wo die .zip Datei erstellt werden soll.
end;