GetFileSystemEntries(Path: String; Pattern: String): IStringList;
Path - directory, which contents must be obtained.
Pattern - character string, according to which a list is filtered.
The GetFileSystemEntries method returns names of all subdirectories and files that are contained in the 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 and more characters, are returned.
"*.abc" - returns files with the 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 the extension *.ab" only.
Sub UserProc(sPath: String; Pattern: String);
Var
Contents: IStringList;
NameDir: String;
Begin
If Directory.Exists(sPath) Then
Contents := Directory.GetFileSystemEntries(sPath, Pattern);
For Each NameDir In Contents Do
Debug.WriteLine(NameDir);
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 subdirectories and files from the specified directory, that have a phrase "sample" in their name, are displayed in the development environment console.
See also: