GetFiles(Pattern: String): IFileInfoList;
Pattern - character string, according to which a list is filtered.
The GetFiles method returns information about 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 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;
Var
Dir: IDirectoryInfo;
Files: IFileInfoList;
FileInf: IFileInfo;
Begin
Dir := New DirectoryInfo.Attach("c:\Work");
If Dir.Exists Then
Files := Dir.GetFiles("*.pef");
For Each FileInf In Files Do
Debug.WriteLine("Complete path: " + FileInf.FullName);
Debug.WriteLine("Creation date: " + FileInf.CreationTime.ToShortDateString);
Debug.WriteLine("Attributes: " + FileInf.Attributes.ToString);
End For;
End If;
Dispose Dir;
End Sub UserProc;
After executing the example, information about files of the specified directory with the "pef" extension and also with the extension that begins with characters "pef" is displayed in the development environment console.
See also: