I would like to use the Directory.GetDirectories method to get all directories with some exclusions. In particular I need to exclude directories that have a hyphen in them. I already found out regular expressions to not work as search patterns. What search pattern would I use?
I would like to use the Directory.GetDirectories method to get all directories with some
Share
Maybe a linq query would be sufficient?
EDIT(More explanation)
The solution above is called “LINQ to Objects”. It is a way of querying collections that implement
IEnumerableorIEnumerable<T>interface. TheGetDirectoriesmethod returnsArrayof string that is eligible to use Linq. There is a lot of stuff about Linq on the internet. To see te power of Linq flick through these examples on MSDN: 101 Linq Samples. BTW Linq is useful to retrieve data from various sources like XML, databases etx.