delphi TZipFile 用法  
官方Delphi 学习QQ群: 682628230(三千人)\n
频道

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
 begin
// işlem tamam
 end
 else
 begin
// işlem hatalı
 end;


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.039371013641357 seconds