I'm trying to open a certain file that I expect to be in a certain folder. If the file is not in the folder I want to show an OpenFileDialog
so the user can browse to where the file is located and tell my program what folder to use. However, I want to limit the OpenFileDialog to only accept that specific file name that I'm looking for... say notepad.exe
. How can I do this?
Try specifiying the file you want to open in file name property of openfiledialog.it will be like.
openFileDialog1.Filename="Note*";
openFileDialog1.Filter = "Exe Files (.exe)|*.exe|All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 1;
If the specified default directory has the file name starting with note,then it will show that file else user can search for file in other directories.For more References,Go to this specifying Filename in openfiledialog