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?
Asked
Active
Viewed 4,130 times
-1
1 Answers
1
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

Community
- 1
- 1

akhil kumar
- 1,598
- 1
- 13
- 26
-
Hi, I have one more question. How do I make it when I press a button it grabs the file im patching and makes a copy of it renames it to blah.exe.bac – Solarflux Jan 10 '15 at 03:15
-
there are function for copying and renaming files in vb.net.use `file.copy(sourcefilename,destinationfilename,false)`.here the boolean argument is for enabling overwrite. – akhil kumar Jan 10 '15 at 04:29