I want to able to search through folders and subfolder names, then if they have a specific pattern on their name, change or remove them from the folder name.
I used the below code but folderNameList return {}
string[] dirs = Directory.GetDirectories(myRootPath, "*", SearchOption.AllDirectories);
string findFolderNamePattern = @"((?i)mydomain.com|sitename(?-i))";
string replacement = " ";
Match folderNameList = Regex.Match(dirs.ToString(), findFolderNamePattern);
foreach (var folder in folderNameList.ToString())
{
folder = Regex.Replace(folder.ToString(), replacement);
}
Also you can see the regex here
ToStringingdirs? That won't give you what you want.folderNameList.cannot convert from 'string[]' to 'string'folder = "whatever"won't change the source list.