IDirectoryInfo.GetFileSystemInfos

Syntax

GetFileSystemInfos(Pattern: String): IFileSystemInfoList;

Parameters

Pattern - a 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 parameter Pattern.

Comments

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:

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 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:

IDirectoryInfo