IDirectoryInfo.GetFileSystemInfos

Syntax

GetFileSystemInfos(Pattern: String): IFileSystemInfoList;

Parameters

Pattern - character string, according to which a list is filtered.

Description

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.

Comments

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:

Example

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:

IDirectoryInfo