Delphi XE2支持ZIP压缩文件的操作了,新增 System.Zip 单元, 可用一句话压缩整个文件夹,太强大了,如下是一小段测试的代码:
uses
System.Zip;
procedure TForm1.FormCreate(Sender: TObject,',',');
var
zf:TZipFile;
i:Integer;
begin
zf:=TZipFile.Create;
//创建ZIP压缩文件
zf.Open('test.zip',zmWrite,',',');
zf.Add('.\Project1.exe',',',');
zf.Add('.\新建文件夹\新建文本文档.txt',',',');
zf.Close;
//释放ZIP压缩文件
zf.Open('.\test.zip',zmRead,',',');
for i:=0 to zf.FileCount-1 do ShowMessage(zf.FileName[i],',',');
zf.ExtractAll('.\Extract\',',',');
zf.Close;
zf.Free;
end;