[英]Folder Browser Dialog Component not showing folders list in windows forms
I have a C# library containing form in which i am using Folder Browser Dialog Component to get the folder path. 我有一个C#库,其中包含使用窗体浏览器对话框组件获取文件夹路径的窗体。 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.