GetFiles(Path: String; Pattern: string): IStringList;
Path - a directory content of which should be obtained.
Pattern - a character string according to which a list is filtered.
The GetFiles method returns a list of files of a directory, passed by the parameter Path in accordance with the filter Pattern.
Character string Pattern may contain following global characters:
| Global character | Description |
| * | Zero or more characters. |
| ? | Exactly one character. |
Characters different from global characters represent themselves. If files extension is specified in a character string, the search is performed as below:
If three extension characters are specified in Pattern, files, extension of which has three and more characters, are returned.
"*.abc" - returns files with extension "*.abc", "*.abcd", "*.abcde" and so on.
If one, two or more than three extension characters are specified in Pattern, files with given length of extension are returned.
"*.ab" - returns files with extension "*.ab" only.
Sub UserProc(sPath: String; Pattern: String);
Var
Files: IStringList;
FileName: String;
Begin
If Directory.Exists(sPath) Then
Files := Directory.GetFiles(sPath, Pattern);
For Each FileName In Files Do
Debug.WriteLine(FileName);
End For;
End If;
End Sub UserProc;
While executing this example the existence of a directory specified in the parameter Path is checked. If a directory exists, a list of files, that are contained in it and meet conditions, passed in the parameter Pattern, are displayed in development environment console.
See also: