Eliminar todos los archivos y carpetas de forma recursiva con Delphi
Estoy tratando de eliminar una carpeta y todas sus subcarpetas de forma recursiva, pero no funciona en absoluto, ¿puede alguien verificar el código y decirme qué estoy haciendo mal aquí?
Estoy ejecutando este código a través de D7 en 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;