Hi
How to find all files matches a regex pattern in a folder?
Thanks
Hi
How to find all files matches a regex pattern in a folder?
Thanks
The GetFiles method allows you to specify a wildcard pattern but not really a regex. Another possibility is to simply loop through the files and validate their name against a regex.
IEnumerable<string> files = Directory
.EnumerateFiles(@"c:\somePath")
.Where(name => Regex.IsMatch(name, "SOME REGEX"));
Regex matching of filesystem is not supported you will have to iterate through each of the files in the directory and check them individually