I want to return a list of all the subdirectories in the \'SomeFolder\' directory excluding the \'Admin\' and \'Templates\' directories.
I have th
the opposite of (A || B) is (!A && !B), so in your code it should be &&, not ||...
You can do something like:
//list your excluded dirs
private List<string> _excludedDirectories= new List<string>() { "Admin", "Templates" };
//method to check
static bool isExcluded(List<string> exludedDirList, string target)
{
return exludedDirList.Any(d => new DirectoryInfo(target).Name.Equals(d));
}
//then use this
var filteredDirs = Directory.GetDirectories(path).Where(d => !isExcluded(_excludedDirectories, d));