GetFileSystemInfos(Pattern: String): IFileSystemInfoList;
Pattern - a character string according to which a list is filtered.
The GetFileSystemInfos method returns information about subdirectories and files in a directory. A list is filtered according to a filter passed by the parameter 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;
Var
Dir: IDirectoryInfo;
Contents: IFileSystemInfoList;
Content: IFileSystemInfo;
Begin
Dir := New DirectoryInfo.Attach("c:\Work");
If Dir.Exists Then
Contents := Dir.GetFileSystemInfos("*sample*");
For Each Content In Contents Do
If Content.Extension <> "" Then
Debug.WriteLine("Complete path to a file: " + Content.FullName);
Else
Debug.WriteLine("Complete path to a directory: " + Content.FullName);
End If;
Debug.WriteLine("Creation date: " + Content.CreationTime.ToShortDateString);
Debug.WriteLine("Attributes: " + Content.Attributes.ToString);
End For;
End If;
Dispose Dir;
End Sub UserProc;
After executing this example, information about subdirectories and files of a specified directory that have in its name phrase "sample" is displayed in development environment console.
See also: