Aryéh Radlé
Aryéh Radlé

Reputation: 1332

Searching for files using sub-directory wildcard (glob)

I have a main configuration file config.yml.

In it, I would like to specify list of 'included' config files. The includes can be resolved using search patterns, which include wild cards.

For example:

includes:
  - /plugins/**/config.yml
  - /etc/**/config.yml

Currently, the only way to search for files in .net is by calling Directory.GetFile, but this method has to receive explicitly SearchOption whether to include all subdirectories or only the top one in the search.

It doesn't support "search all sub directories" (/**/) pattern.

Is there any simple way to achieve this?

Upvotes: 0

Views: 142

Answers (1)

Thorkil Holm-Jacobsen
Thorkil Holm-Jacobsen

Reputation: 7676

The file pattern is called a “glob”. To my knowledge there is no functionality in the core libraries to handle globs. I would look for a third-party glob library.

Upvotes: 1

Related Questions