function ListFiles(path: string): TStringList; var SearchRec: TSearchRec; found: integer; begin result := TStringList.Create; found := FindFirst(path + '' + '*.*', faAnyFile, SearchRec); if not DirectoryExists(path) then begin Result.Clear; exit; end; while found = 0 do begin if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') and (SearchRec.Attr <> faDirectory) then begin if ExtractFileExt(SearchRec.Name) = '.dfm' then result.Add(path + '' + SearchRec.Name); end else if (SearchRec.Attr = faDirectory) and (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then begin Result.AddStrings(ListFiles(path + '' + SearchRec.Name)); end; found := FindNext(SearchRec); end; FindClose(SearchRec); end;
http://blog.csdn.net/y281252548/article/details/51659208