Yes, you can use the
OpenFileDialog
to achieve this, and set the InitialDirectory to the directory that you first want to search for, but there isn't a "Name" specific search, only extension specific search can be made, like searching for an Office file or a Web document etc.
However, if I had to do this project. I wouldn't use
OpenFileDialog
, instead I would have made a use of
System.IO
namespace and enumerated among the directories and look for my file. Because once inside these
System.IO
namespace's
File
or
Directory
class I can check for each file, by their types, create time or their names etc.
Once I would have caught all of the files inside the directory, a simple name check like this
if(Path.GetFileName(file) == nameToSearch) {
}
File must come from the directory's file collection.
This second method would have given me much control, but the one thing "open the files in Window explorer" would now lag, since we can't filter the files by their names unless we use a Windows based search. But this method would let us, create a simple UI to show all of the possible files, and directories to create in the UI for the user to navigate.