GetFileSystemInfos(Pattern: String): IFileSystemInfoList;
Pattern - 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 Pattern parameter.
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;
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 the example information about subdirectories and files of the specified directory that have in its name phrase "sample" is displayed in the development environment console.
See also: