首页 > 解决方案 > 无压缩压缩 (Delphi)

问题描述

我正在使用Delphi原生提供的TZipFile类,我想知道是否可以在不压缩的情况下打包/解包,类似于unix中的tar命令。在这种情况下,我们寻求将文件提取和写入包的最大效率. 谢谢。

标签: delphiziptar

解决方案


解决方案: zip-without-compression-delphi

关键是在 TZipFile.Add 过程中使用ZcStored选项。

附件是一个回答我的问题的工作示例,以防万一有人遇到汤姆布伦伯格友好解决的问题

// 使用 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


推荐阅读