I am using Directory.GetDirectories()
to get a list of folders that meet a certain criteria by using its searchPattern
parameter.
I am only looking for any folders containing a specific word, say alphabet
, my code is as follows:
Directory.GetDirectories(rootToSearch, "*alphabet*")
But, there is a common abbreviation that I know to expect for this word, say abc
. If I was searching in Windows File Explorer I could search for *alphabet* OR *abc*
and it would work as expected, however putting this as the searchPattern
results in the function finding no folders, presumably because it is taking it as one search term including OR
as a literal, instead of 2 terms delineated with OR
.
Is there any way to achieve an OR
statement in the search pattern? The MSDN says:
The search string to match against the names of subdirectories in path. This parameter can contain a combination of valid literal and wildcard characters, but it doesn't support regular expressions.
So I know that I can't use Regular Expressions. I tried using |
, but that results in an Illegal characters in path
error.