Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Our InspectDirectories method calls the static GetFiles method on the Directory class to find the files we’re interested in. Example 11-5 shows the relevant code.
var searchOption = recurseIntoSubdirectories ?
SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
// Get the path of every file in every directory we're searching.
var allFilePaths = from directory in directoriesToSearch
from file in Directory.GetFiles(directory, "*.*",
searchOption)
select file; |