IDirectoryInfo.GetFiles

Syntax

GetFiles(Pattern: String): IFileInfoList;

Parameters

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

Description

The GetFiles method returns information about 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;
    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:

IDirectoryInfo