Delphi TZipFile 用法


本文整理自网络,侵删。

 
{-------------------------------------------------------------------------------
   -Klas?r S?k??t?rma  ZIP
-------------------------------------------------------------------------------}
function TfrmMain.zipFolder(ArchiveName, FilePath: String): boolean;
var Zip:TZipFile;
begin
 Zip:=TZipFile.Create;
 try

  zip.ZipDirectoryContents(ArchiveName,FilePath );

  Result:=true;
 except
  REsult:=false;
 end;
 FreeAndNil(zip);

end;

{-------------------------------------------------------------------------------
   -Dosya S?k??t?rma  ZIP
-------------------------------------------------------------------------------}
function TfrmMain.zipFile(ArchiveName, Filename: String): boolean;
var Zip:TZipFile;
begin
 Zip:=TZipFile.Create;
 try
  if FileExists(ArchiveName) then
   DeleteFile(ArchiveName);
  zip.Open(ArchiveName,zmWrite);
  zip.Add(Filename);
  zip.Close;
  Result:=true;
 except
  REsult:=false;
 end;
 FreeAndNil(zip);
end;


{-------------------------------------------------------------------------------
   -Dosya A?ma UNZIP
-------------------------------------------------------------------------------}
function TfrmMain.UnZipFile(ArchiveName, Path: String): boolean;
var Zip:TZipFile;
begin

 Zip:=TZipFile.Create;
 try
   zip.Open(ArchiveName,zmRead);
   zip.ExtractAll(Path);
   zip.Close;
   result:=true;
 except
  result:=false;
 end;
 zip.Free;

end;

用法:
uses zip;

if zipFolder('c:\1\test.zip','c:\2') then<br>
 begin<br>
// i?lem tamam<br>
 end<br>
 else<br>
 begin<br>
// i?lem hatal? <br>
 end;<br>

相关阅读 >>

Delphi tidhttp 登录网页封装

Delphi dbgrid中实现copy、paste功能

Delphi urldownloadtofile 实现文件下载

Delphi indy smtp 发送邮件

Delphi下调用有返回值的存储过程

Delphi 去除 tstringlist 重复项

Delphi 监控系统文件操作

Delphi xe7android应用启用蓝牙

Delphi daysbetween 用法片段

Delphi 如何使用sendmessage发送后台组合键消息(ctrl+xxx)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...