IDirectory.GetFiles

Syntax

GetFiles(Path: String; Pattern: string): IStringList;

Parameters

Path - directory, which contents must be obtained.

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

Description

The GetFiles method returns a list of files of a directory passed by the Path parameter in accordance with the Pattern filter.

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(sPath: String; Pattern: String);
Var
    Files: IStringList;
    FileName: String;
Begin
    If Directory.Exists(sPath) Then
        Files := Directory.GetFiles(sPath, Pattern);
        For Each FileName In Files Do
            Debug.WriteLine(FileName);
        End For;
    End If;
End Sub UserProc;

On executing the example the existence of the directory specified in the Path parameter is checked. If the directory exists, a list of files, that are contained in it and meet the condition passed in the Pattern parameter, are displayed in the development environment console.

See also:

IDirectory