简体   繁体   中英

Zip without compression (Delphi)

I am using the TZipFile class provided natively by Delphi and I am wondering if it is possible to pack / unpack without compression , similar to the tar command in unix.In this case, we seek the greatest efficiency in extracting and writing files into a package. Thanks.

Solution: zip-without-compression-delphi

The key is to use the ZcStored option in the TZipFile.Add procedure.

Attached is a working example that answers my question, in case anyone falls into the same issue that has been kindly resolved by Tom Brunberg

// Uses system.zip;

Procedure MakeZipFile;
Var
 fZip: TzipFile;
 PathZip, MyPathFile: String;
begin
 fZip := TZipFile.Create;
 Try
   PathZip := 'C:\example.zip';
   MyPathFile := 'C:\myfile.txt';
   fZip.Open(PathZip, zmWrite);
   fZip.Add(MyPathFile, '', ZcStored); // Thanks Tom
   fZip.Close;
 Finally
   fZip.Free; 
 end;
end;

压缩类型 Tzipfile Delphi

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM