GetFiles(Path: String; Pattern: string): IStringList;
Path - directory, which contents must be obtained.
Pattern - character string, according to which a list is filtered.
The GetFiles method returns a list of files of a directory passed by the Path parameter in accordance with the Pattern filter.
The Pattern character string may contain the following wildcards:
Wildcard | Description |
* | Zero or more characters. |
? | Exactly one character. |
Characters different from wildcards represent themselves. If files extension is specified in a character string, the search is executed as below:
If three extension characters are specified in Pattern, the files, which extension has three or 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, the files with the specified 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;
On executing the example the existence of the directory specified in the Path parameter is checked. If the directory exists, a list of files, that are contained in it and meet the condition passed in the Pattern parameter, are displayed in the development environment console.
See also: