| [Overview][Constants][Types][Classes][Procedures and functions][Index] |
Returns the list of files in the specified path matching the search criteria.
Source position: fileutil.pas line 183
function FindAllFiles( |
const SearchPath: string; |
const SearchMask: string = ''; |
SearchSubDirs: Boolean = True; |
DirAttr: Word = faDirectory; |
MaskSeparator: Char = ';'; |
PathSeparator: Char = ';' |
):TStringList; overload; |
AList: TStrings; |
const SearchPath: string; |
const SearchMask: string = ''; |
SearchSubDirs: Boolean = True; |
DirAttr: Word = faDirectory; |
MaskSeparator: Char = ';'; |
PathSeparator: Char = ';' |
); overload; |
SearchPath |
|
Base path for searching files. |
SearchMask |
|
A list of masks, separated by a semicolon (;) to which found files should match. |
SearchSubDirs |
|
True to search sub-directories in the process. |
PathSeparator |
|
If search recursively sub directories. |
The StringList is created in the FindAllFiles function; you should not instantiate it before calling the function.
AList |
|
TStringList used to store file names matching the search criteria. |
SearchPath |
|
Base path for searching files. |
SearchMask |
|
A list of masks, separated by a semicolon (;) to which found files should match. |
SearchSubDirs |
|
True to search sub-directories in the process. |
PathSeparator |
|
If search recursively sub directories. |
FindAllFiles is an overloaded routine used to populate a TStringList class instance with a list of files match the specified search criteria. The procedure variant uses an existing TStringList class instance to store the matching file names. The function variant creates the TStringList class instance used as the return value for the method.
| Remark: | The function variant of FindAllFiles creates the string list internally. This may seem very convenient at first, but it is very easy to create memory leaks if string list instances are not freed properly. |
uses FileUtil; var PascalFiles: TStringList; begin PascalFiles := TStringList.Create; try FindAllFiles(PascalFiles, LazarusDirectory, '*.pas;*.pp;*.p;*.inc', true); //find e.g. all pascal sourcefiles ShowMessage(Format('Found %d Pascal source files', [PascalFiles.Count])); finally PascalFiles.Free; end; end; // or begin //No need to create the stringlist; the function does that for you PascalFiles := FindAllFiles(LazarusDirectory, '*.pas;*.pp;*.p;*.inc', true); //find e.g. all pascal sourcefiles try ShowMessage(Format('Found %d Pascal source files', [PascalFiles.Count])); finally PascalFiles.Free; end; end;