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 29 30 31 32 33 34 35 36 37 38
| {* ----------------------------------------------------------------------- }
procedure GetListFile(const PathFile: string; ResultList: TStrings; Recurse: Boolean = False);
var
SearchRec: TSearchRec;
begin
ResultList.BeginUpdate();
try
if not Recurse then
ResultList.Clear();
// '*' ou '*.*' Renvoie '.' et '..'
if SysUtils.FindFirst(PathFile + '*', faAnyFile, SearchRec) = 0 then
begin
try
repeat
if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
begin
if Recurse then
begin
if (SearchRec.Attr and faDirectory) <> 0 then // Dossier
GetListFile(IncludeTrailingPathDelimiter(PathFile + SearchRec.Name), ResultList, True) // C'est un Dossier, on cherche les fichiers qu'il contient !
else
ResultList.Add(PathFile + SearchRec.Name) // Fournie Racine + Nom du Fichier
end
else
if (SearchRec.Attr and faDirectory) = 0 then // Fichier
ResultList.Add(SearchRec.Name); // Fourni juste le nom du Fichier
end;
until SysUtils.FindNext(SearchRec) <> 0;
finally
SysUtils.FindClose(SearchRec);
end;
end;
finally
ResultList.EndUpdate();
end;
end; |
Partager