?
Solved

Browse for Directory in VB.NET

Posted on 2003-03-31
4
Medium Priority
?
1,547 Views
Last Modified: 2012-06-21
I need to have the user pick a directory on the hard disk, not a file.  Can you do this with an OpenFileDialog?  Do you need another control?  What control?  Can you include a snippet of code to show me how to create this directory picker?
0
Comment
Question by:curmudgeon42
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 200 total points
ID: 8239670
0
 
LVL 7

Expert Comment

by:Joe_Griffith
ID: 8239931
Imports System.Windows.Forms
Imports System.Windows.Forms.Design

Public Class clsSpFolderBrowser
  Inherits FolderNameEditor
  Dim mo_FB As New FolderBrowser()

  Public Sub New()
    MyBase.new()
    mo_FB.Style = FolderNameEditor.FolderBrowserStyles.RestrictToFilesystem
    mo_FB.StartLocation = FolderBrowserFolder.Desktop ' Seems to be limited to this enumeration
  End Sub

  Public Sub ShowDialog()
    mo_FB.ShowDialog()
  End Sub

  Public ReadOnly Property DirectoryPath() As String
    Get
      Return mo_FB.DirectoryPath
    End Get
  End Property

  Public WriteOnly Property Description() As String
    Set(ByVal Value As String)
      mo_FB.Description = Value
    End Set
  End Property
End Class
   
Dim po_FolderBrowser As New clsSpFolderBrowser()
    po_FolderBrowser.Description = "Select a folder"
    po_FolderBrowser.ShowDialog()
    If po_FolderBrowser.DirectoryPath <> "" Then
      x = po_FolderBrowser.DirectoryPath
    End If
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 8240124
0
 

Author Comment

by:curmudgeon42
ID: 8240709
Thanks that was perfect.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

770 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