IDirectory.GetFiles

Syntax

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

Parameters

Path - a directory content of which should be obtained.

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

Description

The GetFiles method returns a list of files of a directory, passed by the parameter Path in accordance with the filter 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(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;

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

See also:

IDirectory