I'm using below code to look for files which carry any of these keywords. For now I could only look for kword1 and if no files found, I start repeating the search for kword2. I'm wondering if there is a more efficient way to look for kword1 or kword2 in the same search. I've been looking on multiple sources and I cant seem to find the way.
Here is what I`ve done so far:
string[] matches =
Directory
.GetFiles(
path1,
"*" + kword1 + "*.txt",SearchOption.AllDirectories
);
Here are a couple of tricks you can do
using System.Linq. First set up the test run like this:The
Whereexpression retrieves all the files, then filters them according tokword1andkword2.The
Selectexpression selects only the file name portion of the full path.