Usuń wszystkie pliki i foldery rekurencyjnie za pomocą Delphi
Próbuję rekursywnie usunąć folder i wszystkie jego podfoldery, ale w ogóle nie działa, więc czy ktoś może sprawdzić kod i powiedzieć, co tutaj robię źle?
Używam tego kodu przez D7 w systemie Windows XP
if FindFirst (FolderPath + '\*', faAnyFile, f) = 0 then
try
repeat
if (f.Attr and faDirectory) <> 0 then
begin
if (f.Name <> '.') and (f.Name <> '..') then
begin
RemoveDir(FolderPath +'\'+ f.Name);
end
else
begin
//Call function recursively...
ClearFolder(FolderPath +'\'+ f.Name, mask, recursive);
end;
end;
until (FindNext (f) <> 0);
finally
SysUtils.FindClose (f)
end;
end;