I have a C# library containing form in which i am using Folder Browser Dialog Component to get the folder path. Form is shown during installation of my application using Custom Installer. When click on browse button to show folder browser dialog. Dialog opened but there was no folder list, blank dialog is shown with OK and Cancel button. I am using the below code:
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
folderBrowserDialog.RootFolder = Environment.SpecialFolder.MyComputer;
if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
{
txtDBPath.Text = folderBrowserDialog.SelectedPath;
btnSelectFile.Enabled = true;
}
How can i solve this issue. thanks
I solved this problem.
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Try
Dim MyThread As New Threading.Thread(AddressOf ShowMyFolderBrowserDialog)
MyThread.SetApartmentState(Threading.ApartmentState.STA)
MyThread.Start()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Setup")
End Try
End Sub
Private Sub ShowMyFolderBrowserDialog()
Try
Me.FolderBrowserDialog1.RootFolder = Environment.SpecialFolder.MyComputer
Me.FolderBrowserDialog1.Description = "Select folder"
If System.IO.Directory.Exists(Me.TextBox1.Text) Then
Me.FolderBrowserDialog1.SelectedPath = Me.TextBox1.Text
End If
If Me.FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
Me.TextBox1.Text = Me.FolderBrowserDialog1.SelectedPath
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Setup")
End Try
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.