GetFiles(Pattern: String): IFileInfoList;
Pattern - a 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 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;
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 this example, information about files of a specified directory with extension "pef" and also with extension that begins with characters "pef" is displayed in development environment console.
See also: