subdirectory - C# - SearchOption.AllDirectories but not in certain folders -


i'd use directory.getfiles(source, file, searchoption.alldirectories))

but not search in specific folders.

how can manage that? thank you!

using getfiles searchoption.alldirectories search directories. if aren't worried performance hit of searching directories, , want filter results, can this:

var pathstoavoid = new list<string> { @"c:\public\temp\", @"c:\public\media\" };  var files = directory.getfiles(@"c:\public\", "temp.txt", searchoption.alldirectories)     .where(filepath => !pathstoavoid.any(path =>     filepath.startswith(path, stringcomparison.ordinalignorecase))); 

otherwise, need manually search directories care 1 @ time.


Comments