本文整理自网络,侵删。
{------------------------------------------------------------------------------- -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>
相关阅读 >>
检测是否按下键盘或鼠标,如果超过5分钟没有操作则认为用户已经离开
Delphi xe6 android 界面皮肤美化 用stylebook
Delphi xe5 json与Delphi object的互换
更多相关阅读请进入《Delphi》频道 >>