IDirectoryInfo.GetFiles

Syntax

GetFiles(Pattern: String): IFileInfoList;

Parameters

Pattern - a 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 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;
    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:

IDirectoryInfo