File chooser dialog in Windows Foms programming. How to create?

I am writing a Windows Form desktop applicatiion. I need to allow for the application user to browse to
a file directory and to select a file to be uploaded. Now in the toolbox I see a control named
"FolderBrowserDialog". If I then drag and drop this control onto my windows form, I get an icon
at the bottom of the form labeled "folderBrowserDialog1".

Yet I do not get a button on the form that I can see which will allow the user to select the file
to be uploaded? Does this work differently in windows programming? Because I am expecting to see a button which the application user can press and then the file chooser dialog box displays.
LVL 2
brgdotnetcontractorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lazyberezovskyCommented:
1) drag OpenFileDialog to your form
2) drag button to form
3) double click button
4) in button event handler add

private void button1_Click(object sender, EventArgs e)
{
    if (openFileDialog1.ShowDialog() == DialogResult.OK)
    {
        //Use openFileDialog1.FileName to get selected file name              
    }
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CuteBugCommented:
When you drag and drop the FolderBrowserDialog to your form you are just adding a component to your Form class. It will not show anything on Form. It will add a member to your Form class (like folderBrowserDialog1). You need to call its ShowDialog method to show it.

FolderBrowserDialog will let you choose a folder. In order to select a file you need to use OpenFileDialog.

http://dotnetperls.com/openfiledialog
http://www.java2s.com/Code/CSharp/GUI-Windows-Form/OpenFileDialogwithfiletypes.htm
http://dotnetdud.blogspot.com/2009/01/openfiledialog-in-c-how-to-use.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.