The OpenFileDialog class is defined in Windows.Forms class. You need to add to reference to System.Windows.Form.dll library and call using System.Windows.Forms before using the class.
The OpenFileDialog class can be used to open a file similar to CFileDialog's Open method in VC++. This class is derived from FileDialog. OpenFile method of this class opens a file which can be read by steam.
In this sample code, I use OpenFileDialog class to browse a file.
- OpenFileDialog fdlg = new OpenFileDialog();
- fdlg.Title = "C# Corner Open File Dialog" ;
- fdlg.InitialDirectory = @"c:\" ;
- fdlg.Filter = "All files (*.*)|*.*|All files (*.*)|*.*" ;
- fdlg.FilterIndex = 2 ;
- fdlg.RestoreDirectory = true ;
- if(fdlg.ShowDialog() == DialogResult.OK)
- {
- textBox1.Text = fdlg.FileName ;
- }

FileName member gives you the name of the selected file.
Read more >> OpenFileDialog In C#

Md NaimPosted Mar 14, 2017, 4:01 AM
Dear sir, Am in need of help.. I need ur help to obtain raw data from a network using c# and the same file should be dumped into Mysql.. please help me with c# programming.. please guide me sir..
kalu singh raoPosted Jul 7, 2016, 1:46 AM
Nice...
keerthi saiPosted Nov 10, 2015, 3:26 AM
how to work on asp.net web application?
mahendra kanumurieditedPosted May 30, 2011, 1:02 AMEdited May 30, 2011, 1:17 AM
In that we should have done button, when we click on done button that should store in that location
karthick perumalPosted Feb 8, 2011, 9:52 AM
i need open a new html file, when i press the button(in new browser)...
R JPosted Sep 6, 2010, 9:43 AM
hi.. I have one browse button and one text box. In the browse_button click event, I would like to browse the files and place the path name into textbox. For this i'vw written code like this by using openfile dialog. private void brwsbtn_Click(object sender, EventArgs e) { if (openFD.ShowDialog() == DialogResult.OK) { textBox1.Text = openFD.FileName; } textBox1.Text=""; } So that i am able to select files only. how can i select and place the folders path in textbox. In my application the user should able to select either file or folder through a single browse button. please suggest me how to write code for this. thank you
SachinPosted Jul 29, 2010, 8:25 AM
How to browse the multiple files and get the all file names at a time
sankarshan mridhaPosted Jul 4, 2010, 11:56 AM
want to make a GUI to process multiple file.the GUI will have "browse file" button to browse file from drive.help me with the source code as i am newbiee in C#.
Nitesh TarbaniPosted Jun 30, 2010, 6:56 AM
First of all Thanks for above Information. I have been working on map using C#. I wanna to know how to change the color of map according to different condition for example we use blue color for river etc.....
Surya GiriPosted Feb 26, 2008, 5:04 AM
Hi Mahesh, I am new in c#. I try to connect the database in sql using c#.. but I am unable to do it... please can u write me in details....
Srikanth VarmaPosted Jun 27, 2007, 3:39 AM
Hi mahesh, it's giving follwoing error "It is invalid to show a modal dialog or form when the application is not running in UserInteractive mode. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."