I have a solution folder in which I have collect all the .dll’s and store in a array list. I have to search all the sub-directories. How to write the LINQ Query?
var r = dir.GetFiles("*.dll")
.Where<FileInfo>(i => i.Name.StartsWith("SAMPLE"))
.ToList();
Is this Correct? For example i 20 dll’s startwith name “SAMPLE”
I would recommend you using the EnumerateFiles method:
or even better use the wildcard pattern to filter instead of filtering in-memory: