Method GetFilesSafe
GetFilesSafe(DirectoryInfo, string, SearchOption)
Recursively retrieves files from the specified directory and its subdirectories matching a given search pattern. This method will skip any inaccessible directories due to permission issues and continue with the next accessible directory.
Declaration
public static IReadOnlyList<FileInfo> GetFilesSafe(this DirectoryInfo directory, string searchPattern, SearchOption searchOption = SearchOption.TopDirectoryOnly)
Parameters
Type | Name | Description |
---|---|---|
DirectoryInfo | directory | The directory from which to start the search. |
string | searchPattern | The search string to match against the names of files in the directory. |
SearchOption | searchOption |
Returns
Type | Description |
---|---|
IReadOnlyList<FileInfo> | A list of FileInfo objects representing the files found that match the search pattern. |