findFile

Tries to find a single file matching the given pattern.

string
findFile
(
string dir
,
string pattern
,
bool recursive = true
,
int maxDepth = -1
)

Parameters

dir string

The directory to search in.

pattern string

A regex pattern to match against each filename.

recursive bool

Whether to recursively search subdirectories.

maxDepth int

How deep to search recursively. -1 indicates infinite recursion.

Return Value

Type: string

The single matching file that was found, or null if no match was found, or if multiple matches were found.

Meta