I was wondering what would be a good way to scan a directory that has characters you are not sure of.
For example, I want to scan
C:\Program\Version2.*\Files
Meaning
- The folder is located in
C:\Program Version2.*could be anything likeVersion2.33,Version2.1, etc.- That folder has a folder named
Filesin it
I know that I could do something like foreach (directory) if contains("Version2."), but I was wondering if there was a better way of doing so.
Directory.EnumerateDirectories accepts search pattern. So enumerate parent that has wildcard and than enumerate the rest:
Note: if path can contain wildcards on any level – simply normalize path and split by “\”, than collect folders level by level.