本文整理自网络,侵删。
function DeleteDirectory(NowPath: string): Boolean; // 删除整个目录var f : TSearchRec; ret: integer; key: string;
begin if not DeleteTree(NowPath) then begin if NowPath[Length(NowPath)] <> '\' then NowPath := NowPath + '\'; key := NowPath + '*.*'; ret := FindFirst(key, faAnyFile, f); while ret = 0 do begin if ((f.Attr and fadirectory) = fadirectory) then begin if (f.Name <> '.') and (f.name <> '..') then DeleteDirectory(NowPath + f.name); end else begin if ((f.Attr and fadirectory) <> fadirectory) then begin deletefile(NowPath + f.name); end; end; ret := FindNext(f); end; findClose(f);
removedir(NowPath);// 如果需要删除文件夹则添加 result := True; end;end;
相关阅读 >>
Delphi 自定义colorbox只显示指定颜色项目 colorbox显示中文颜色名称
Delphi access violations 问题的解决之道
Delphi xe安装 tclientsocket, tserversocket控件
更多相关阅读请进入《Delphi》频道 >>