Need Help: Problems with FolderBrowserDialog

V

Vivek Srivastav

Hi windowsform gurus,
I am struck with a minor problem. The folder browse button, when pressed
opens an empty blank panel with only the description.
What am I doing wrong? Following is the code:

private void btnOpenDir_Click(object sender, System.EventArgs e)
{
folderBrowserDialog = new FolderBrowserDialog();
folderBrowserDialog.Description = "Select JBoss Home Directory";
folderBrowserDialog.ShowNewFolderButton = false;
folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer;
if(folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
this.tbDir.Text = folderBrowserDialog.SelectedPath;
}
}

I would really appreciate any help.
regards
vivek
 
H

Herfried K. Wagner [MVP]

Vivek Srivastav said:
I am struck with a minor problem. The folder browse button, when pressed
opens an empty blank panel with only the description.

Make sure there is no 'MTAThread' attribute specified on your 'void Main'.
Instead use 'STAThread', which ist the default and doesn't need to be
specified, at least in VB.NET.
 
V

Vivek Srivastav

I just checked the other post where you replied about the [STAThread] for
the main method.
However, I have a .Net Installer Class Library, where I need to open a
folderbrowser dialog for the user to specify a directory. I
have put [STAThread] attribute around the event which creates the
FolderBrowserDialog but it still seems blank with only the description, ok
and cancel button.
 

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