Einzelnen Beitrag anzeigen

Andreas L.
(Gast)

n/a Beiträge
 
#6

Re: Leere Verzeichnisse rekursiv löschen

  Alt 7. Mai 2009, 17:25
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?
  Mit Zitat antworten Zitat