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;