?
Solved

How to Display Open Directory Dialogue Box

Posted on 2004-11-30
11
Medium Priority
?
321 Views
Last Modified: 2010-04-24
Hi all,

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

Thank you
0
Comment
Question by:iflash2
8 Comments
 
LVL 1

Expert Comment

by:VBtorment
ID: 12704145
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
 

Author Comment

by:iflash2
ID: 12704285
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
 
LVL 18

Accepted Solution

by:
armoghan earned 500 total points
ID: 12704389
Hi VBtorment,
Try this for 1.0
http://www.codeproject.com/cs/miscctrl/folderbrowser.asp

Cheers!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:koolnurd
ID: 12705112
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
 
LVL 3

Expert Comment

by:jazduck
ID: 12712569
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
 
LVL 18

Expert Comment

by:armoghan
ID: 12713072
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
 
LVL 3

Expert Comment

by:jazduck
ID: 12713188
Your right armoghan, i misread the question slightly.  OpenFileDialog would be correct to select a file, not a folder.
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12916868
Accept Armoghan
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question