Ich hab den Pseudocode von SirThornberry so umgesetzt:
Delphi-Quellcode:
procedure DeleteEmptyDirectories(Path: String);
var
SearchRec: TSearchRec;
IsEmpty: Boolean;
begin
IsEmpty := True;
if FindFirst(IncludeTrailingPathDelimiter(Path) + '*.*', faAnyFile, SearchRec) = 0 then
begin
repeat
if ((SearchRec.Attr and faDirectory) = faDirectory) and (SearchRec.Name <> '..') and (SearchRec.Name <> '.') then
DeleteEmptyDirectories(IncludeTrailingPathDelimiter(Path) + SearchRec.Name)
else
IsEmpty := False;
until (FindNext(SearchRec) <> 0);
FindClose(SearchRec);
end;
if IsEmpty then
RemoveDir(Path);
end;
Funktioniert aber nicht. Was ist denn falsch?