Since you know the root directory you want to search and a string pattern for a filename, you can create a DirectoryInfo with the root directory:
DirectoryInfo dir = new DirectoryInfo(@"E:\");
And then call GetFiles()
to get all the matches. Passing SearchOption.AllDirectories
will ensure the search is recursive.
List<FileInfo> matches =
new List<FileInfo>(dir.GetFiles(partialFilename,
SearchOption.AllDirectories));
Or if you know part of the path (instead of the filename):
List<DirectoryInfo> matches =
new List<DirectoryInfo>(dir.GetDirectories(partialDirectoryName,
SearchOption.AllDirectories));
And then you can navigate to the file from there.