Method FindFirstFile
FindFirstFile(string, string, SearchOption)
Returns the full file name that match a search pattern in a specified path, and optionally searches subdirectories.
public static string? FindFirstFile(string path, string searchPattern, SearchOption searchOption)
Parameters
path
stringThe relative or absolute path to the directory to search. This string is not case-sensitive.
searchPattern
stringThe search string to match against the names of files in path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters. It doesn't support regular expressions.
searchOption
SearchOptionOne of the enumeration values that specifies whether the search operation should include only the current directory or should include all subdirectories. The default value is TopDirectoryOnly.
Returns
- string
The full name (including path) for the first found file in the directory specified by
path
and that match the specified search pattern and search option. Returnsnull
if no file was found.