delphi - 无压缩压缩 (Delphi)
问题描述
我正在使用Delphi原生提供的TZipFile类,我想知道是否可以在不压缩的情况下打包/解包,类似于unix中的tar命令。在这种情况下,我们寻求将文件提取和写入包的最大效率. 谢谢。
解决方案
解决方案: 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;
推荐阅读
- python - 在标准输入中跟踪行号的 Pythonic 方法
- javascript - Vue 从对象中移除所有类原型方法
- spring-boot - spring data jpa中创建或更新的Cascade类型是什么
- c++ - 在 C++ 中刷新字符串流时会发生什么?
- powerapps - 在共享点列表中使用搜索文本框 >500 个项目
- ansible - 如何编写一个可以在失败时运行任务的 ansible 处理程序?
- haskell - 为什么这个 Functor 实例不正确?
- go - 哈希字符串的有限并行
- javascript - Jquery处理多个变量的点击事件
- windows - Windows 中关键容器存储文件的 GUID 后缀是什么?