FolderBrowserDialog hangs in 2005

G

Grumpy Aero Guy

I have created an app that makes use of the FolderBrowserDialog.

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 FolderBrowserDialog1
..RootFolder = Environment.SpecialFolder.Desktop

..SelectedPath = Environment.SpecialFolder.Desktop

..Description = "Please select the desired template(s)..."

If .ShowDialog = DialogResult.Cancel 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?
 
M

Meelis

why you call .ShowDialog twice?

i suggest something like this;

Dim dlResult As DialogResult

dlResult = .ShowDialog

If dlResult = Windows.Forms.DialogResult.Cancel Then
Exit Sub
ElseIf dlResult = Windows.Forms.DialogResult.Ok Then
DestinationPath = .SelectedPath
End If


Meelis
 
G

Grumpy Aero Guy

Fair enough....

BUT, I still hang on the DestinationPath = .SelectedPath line.
 
L

ljh

Here is a folder browser that does not use the component.....

--------------------------------
Imports System.Windows.Forms.Design

Public Class BrowseForFolder
Inherits FolderNameEditor

Public Enum enuFolderBrowserFolder
Desktop = FolderBrowserFolder.Desktop
Favorites = FolderBrowserFolder.Favorites
MyComputer = FolderBrowserFolder.MyComputer
MyDocuments = FolderBrowserFolder.MyDocuments
MyPictures = FolderBrowserFolder.MyPictures
NetAndDialUpConnections =
FolderBrowserFolder.NetAndDialUpConnections
NetworkNeighborhood = FolderBrowserFolder.NetworkNeighborhood
Printers = FolderBrowserFolder.Printers
Recent = FolderBrowserFolder.Recent
SendTo = FolderBrowserFolder.SendTo
StartMenu = FolderBrowserFolder.StartMenu
Templates = FolderBrowserFolder.Templates
End Enum

'The FolderBrowserStyles collection is a member of FolderNameEditor
Public Enum enuFolderBrowserStyles
BrowseForComputer = FolderBrowserStyles.BrowseForComputer
BrowseForEverything = FolderBrowserStyles.BrowseForEverything
BrowseForPrinter = FolderBrowserStyles.BrowseForPrinter
RestrictToDomain = FolderBrowserStyles.RestrictToDomain
RestrictToFilesystem = FolderBrowserStyles.RestrictToFilesystem
RestrictToSubfolders = FolderBrowserStyles.RestrictToSubfolders
ShowTextBox = FolderBrowserStyles.ShowTextBox
End Enum

Public StartLocation As enuFolderBrowserFolder =
enuFolderBrowserFolder.MyDocuments '.BrowseForComputer
Public Style As enuFolderBrowserStyles =
enuFolderBrowserStyles.ShowTextBox

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.DialogResult
With mobjFB
.Description = mstrDescription
.StartLocation = CType(Me.StartLocation,
FolderNameEditor.FolderBrowserFolder)
.Style = CType(Me.Style, FolderNameEditor.FolderBrowserStyles)
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
 
G

gene kelley

property of the control... that's what's baffling...

No such property as DestinationPath for the FolderBrowserDialog

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
With FolderBrowserDialog1
.RootFolder = Environment.SpecialFolder.Desktop
.SelectedPath = Environment.SpecialFolder.Desktop.ToString
.Description = "Please select the desired template(s)..."

If .ShowDialog = Windows.Forms.DialogResult.OK Then
Me.Label1.Text = .SelectedPath


End If
End With
End Sub

Gene
 
G

Grumpy Aero Guy

My Bad..

It is always hanging here... even in debugger:

Me.Label1.Text = .SelectedPath

It's the .selectedpath line that hangs
 
G

gene kelley

My Bad..

It is always hanging here... even in debugger:

Me.Label1.Text = .SelectedPath

It's the .selectedpath line that hangs


Start a new project. Add a FolderBrowserDialog, Button and Label.
Copy the code for the Button1_Click event that I previously posted and
paste it to the button click event in the project. Run the example.

What results do you get?

Gene
 
G

Grumpy Aero Guy

OK... did it ...

(except i used a textbox instead of a lable, which shouldn't matter...)

When I run the project from within VS2005, it works, although the dialog is
VERY sluggish.... takes a LONG time to navigate to "My Computer", acts as
though it'd deciding whether it wants to hang or physically work....

When I build the solution, and run the .exe in the "Release" folder, it
hangs upon selecting a folder in the dialog....

As I indicated before, I have downloaded a few exe s from CodeProject that
use folderbrowsers, and get the SAME hanging.....

Try the exe thing in the release folder several times. I would be curious if
you get a hang.

FWIW, I did a quick google on "folderbrowserdialog hans VS 2005" and get
quite a few "hits"... this one is interesting:

http://groups.google.com/group/micr...6ae9ae3b5af/51c4cb022010b082#51c4cb022010b082

here's MY code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

With FolderBrowserDialog1

..RootFolder = Environment.SpecialFolder.Desktop

..SelectedPath = Environment.SpecialFolder.Desktop.ToString

..Description = "Please select the desired template(s)..."

If .ShowDialog = Windows.Forms.DialogResult.OK Then

Me.TextBox1.Text = .SelectedPath



End If

End With

End Sub
 
G

Grumpy Aero Guy

BTW, a re-boot gives you one shot at it working. Any second attempt, it
hangs. I get similiar behavior described via the link in the previous
e-mail.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top