本文整理自网络,侵删。
function TForm1.IsDirEmpty(const ADir: String): Boolean;var sPath,s: String; sr: TsearchRec; b: Boolean;begin Result := True; s := ''; if Copy(ADir,Length(ADir) - 1,1) <> '\' then s := '\'; sPath := ADir + s + '*.*'; if FindFirst(sPath,faAnyFile, sr) = 0 then repeat b := (sr.Name <> '.') and (sr.Name <> '..'); if b then Break; until FindNext(sr) <> 0; Result := not b; FindClose(sr);end;
function IsEmptyDir(sDir: String): Boolean;
var
sr: TsearchRec;
begin
Result := True;
if Copy(sDir, Length(sDir) - 1, 1) <> '\' then sDir := sDir + '\';
if FindFirst(sDir + '*.*', faAnyFile, sr) = 0 then
repeat
if (sr.Name <> '.') and (sr.Name <> '..') then
begin
Result := False;
break;
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
function IsEmpty(path: String): Boolean;var f: TSearchRec; hasNext: Boolean;begin Result := True; path := IncludeTrailingPathDelimiter(path); hasNext := FindFirst(path + '*.*', faAnyFile, f) = 0; while hasNext do begin if (f.Name <> '.') and (f.Name <> '..') then begin Result := False; Break; end; hasNext := FindNext(f) = 0; end; FindClose(f);end;
相关阅读 >>
更多相关阅读请进入《Delphi》频道 >>