Here is a folder browser that does not use the component.....
--------------------------------
Imports System.Windows. Forms.Design
Public Class BrowseForFolder
Inherits FolderNameEdito r
Public Enum enuFolderBrowse rFolder
Desktop = FolderBrowserFo lder.Desktop
Favorites = FolderBrowserFo lder.Favorites
MyComputer = FolderBrowserFo lder.MyComputer
MyDocuments = FolderBrowserFo lder.MyDocument s
MyPictures = FolderBrowserFo lder.MyPictures
NetAndDialUpCon nections =
FolderBrowserFo lder.NetAndDial UpConnections
NetworkNeighbor hood = FolderBrowserFo lder.NetworkNei ghborhood
Printers = FolderBrowserFo lder.Printers
Recent = FolderBrowserFo lder.Recent
SendTo = FolderBrowserFo lder.SendTo
StartMenu = FolderBrowserFo lder.StartMenu
Templates = FolderBrowserFo lder.Templates
End Enum
'The FolderBrowserSt yles collection is a member of FolderNameEdito r
Public Enum enuFolderBrowse rStyles
BrowseForComput er = FolderBrowserSt yles.BrowseForC omputer
BrowseForEveryt hing = FolderBrowserSt yles.BrowseForE verything
BrowseForPrinte r = FolderBrowserSt yles.BrowseForP rinter
RestrictToDomai n = FolderBrowserSt yles.RestrictTo Domain
RestrictToFiles ystem = FolderBrowserSt yles.RestrictTo Filesystem
RestrictToSubfo lders = FolderBrowserSt yles.RestrictTo Subfolders
ShowTextBox = FolderBrowserSt yles.ShowTextBo x
End Enum
Public StartLocation As enuFolderBrowse rFolder =
enuFolderBrowse rFolder.MyDocum ents '.BrowseForComp uter
Public Style As enuFolderBrowse rStyles =
enuFolderBrowse rStyles.ShowTex tBox
Private mstrDescription As String = "Please select a directory below:"
Private mstrPath As String = String.Empty
Private mobjFB As New FolderBrowser()
'Adds Description to dialog box
Public Property Description() As String
Get
Return mstrDescription
End Get
Set(ByVal Value As String)
mstrDescription = Value
End Set
End Property
Public ReadOnly Property Path() As String
Get
Return mstrPath
End Get
End Property
Public Function ShowBrowser() As System.Windows. Forms.DialogRes ult
With mobjFB
.Description = mstrDescription
.StartLocation = CType(Me.StartL ocation,
FolderNameEdito r.FolderBrowser Folder)
.Style = CType(Me.Style, FolderNameEdito r.FolderBrowser Styles)
Dim dlgResult As DialogResult = .ShowDialog
If dlgResult = DialogResult.OK Then
mstrPath = .DirectoryPath
Else
mstrPath = String.Empty
End If
Return dlgResult
End With
End Function
End Class
--------------------------------
Usage is like....
--------------------------------
Dim objFB As New BrowseForFolder ()
If objFB.ShowBrows er = Windows.Forms.D ialogResult.OK Then
MessageBox.Show (objFB.Path)
End If
--------------------------------
"Grumpy Aero Guy" <fb@beerme.or g> wrote in message
news:k5******** *********@torna do.ohiordc.rr.c om...
I have created an app that makes use of the FolderBrowserDi alog.
Upon building the app, installing and running it, and invoking the form
using the dialog, it hangs upon folder selection and goes "not responding"
Upon debugging, it hangs as well upon executing the line that extracts the
selected folder without further explanation. All looks well in the
debugger prior to executing the line marked with <<<<<< below. When I
step over that line, it hangs.
With FolderBrowserDi alog1
.RootFolder = Environment.Spe cialFolder.Desk top
.SelectedPath = Environment.Spe cialFolder.Desk top
.Description = "Please select the desired template(s)..."
If .ShowDialog = DialogResult.Ca ncel Then
Exit Sub
End If
If .ShowDialog = DialogResult.OK Then
DestinationPath = .SelectedPath <<<<<<<<
End If
End With
I noticed the same behavior from a downloaded exe created in VS2005 using
the folderbrowser --- thus, I have two indenpent instances of the
browserdialog hanging, one not of my creation.
Any insights?
--
Grumpy Aero Guy