I want to iterate folders with Directory.EnumerateDirectories
and check if there are folders starting with a specific pattern in each path.
static void SearchFolder(string searchDirectory)
{
foreach (var path in Directory.EnumerateDirectories(searchDirectory))
{
var pattern = folderName + @"\10.*";
var isProjectFolderMatch = Regex.Match(path, pattern);
if (isProjectFolderMatch.Success)
{
Console.WriteLine($"found: {path}");
}
}
}
But the regex match throws an error
'C:\Folder\10.*' - Reference to undefined group number 1.'
How can I build a dynamic pattern in this way?
Thanks!