private static void RemoveDirectories(string rootDir, string[] dirNames)
{
foreach(string dir in Directory.GetDirectories(rootDir))
{
string simpleName = Path.GetFileName(dir);
if(Array.IndexOf(dirNames, simpleName) != -1)
{
//delete if the name matches one of the directory names to delete
string fullDirPath = Path.GetFullPath(dir);
Directory.Delete(fullDirPath,true);
}
else//not a match, so check children
{
RemoveDirectories(dir,dirNames);
//recurse, checking children for them
}
}
}