How to Display Open Directory Dialogue Box

Hi all,

Instead of of selecting a file, I'm trying to let the user select a directory in a dialogue box.

Thank you
iflash2Asked:
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.

VBtormentCommented:
Hai,

Use the FolderBrowser object from the toolbar, then use this code:

        FolderBrowserDialog1.SelectedPath = "C:\TEMP"
        FolderBrowserDialog1.ShowNewFolderButton = True
        FolderBrowserDialog1.Description = "Select folder..."
        FolderBrowserDialog1.ShowDialog(Me)
        If FolderBrowserDialog1.ShowDialog(Me) = DialogResult.OK Then
            TextBox2.Text = FolderBrowserDialog1.SelectedPath
        End If
0
iflash2Author Commented:
Hi VBtorment,

I think im using the older version of VB.NET (2002)... there is no FolderBrowserDialog box.. is there another way to do this?
0
armoghanCommented:
Hi VBtorment,
Try this for 1.0
http://www.codeproject.com/cs/miscctrl/folderbrowser.asp

Cheers!
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
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

koolnurdCommented:
Use OpenFileDialog control and add the following code.


Dim OpenDig As New OpenFileDialog()
        OpenFileDialog1.Title = "Title of the Dialog Box"
        OpenFileDialog1.DefaultExt = ".doc"
        OpenFileDialog1.ShowDialog
        End If
0
jazduckCommented:
koolnurd's answer looks about right, just thought id add what to do after your user has selected a file.

Once the user has selected a file, you can retrieve the path of the file/folder selected using OpenFileDialog1.FileName

Then you can instruct your app to do whatever you require using that path.

Jaz
0
armoghanCommented:
I dont agree with jazduck, Directory selection is a separate thing.
If you do not have a file in the directory in koolnurd method you cannt select that directory
0
jazduckCommented:
Your right armoghan, i misread the question slightly.  OpenFileDialog would be correct to select a file, not a folder.
0
armoghanCommented:
Accept Armoghan
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
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.