1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| function slach(chemin : string) : string;
begin
chemin := trim(chemin);
if rightstr(chemin, 1) <> '\' then result := chemin + '\' else result := chemin;
end;
procedure ScanFiles(NomDossier : string ; subFolder : boolean);
var
hFind : TSearchRec;
begin
NomDossier := slach(NomDossier);
if FindFirst(NomDossier + '*.*', FaAnyFile, hFind) = 0 then
begin
repeat
if (hFind.Attr and faDirectory) <> faDirectory then
begin
Application.ProcessMessages;
DeleteFile(NomDossier + hFind.Name);
end else
begin
if (hFind.Name <> '.') and (hFind.Name <> '..') then
if subFolder = True then ScanFiles((slach(NomDossier) + hFind.Name), subFolder);
end;
until FindNext(hFind) <> 0;
FindClose(hFind);
Application.ProcessMessages;
end;
end; |
Partager