首页 > 代码库 > [VB.NET]调用系统的文件夹选择对话框
[VB.NET]调用系统的文件夹选择对话框
以下示例代码展示如何调用系统的文件夹选择对话框:
1 Private Function SelectFolder(ByVal Describe As String, Optional ByVal ShowNewFolder As Boolean = True) As String2 Using nOpen As New System.Windows.Forms.FolderBrowserDialog()3 nOpen.Description = Describe4 nOpen.ShowNewFolderButton = ShowNewFolder5 nOpen.ShowDialog()6 Return nOpen.SelectedPath7 End Using8 End Function
调用方式:
1 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 2 Dim _selectedFolder As String = SelectFolder("请选择安装目录", True) ‘显示选择安装目录界面,同时允许创建新文件夹 3 MsgBox(_selectedFolder) 4 End Sub 5 6 Private Function SelectFolder(ByVal Describe As String, Optional ByVal ShowNewFolder As Boolean = True) As String 7 Using nOpen As New System.Windows.Forms.FolderBrowserDialog() 8 nOpen.Description = Describe 9 nOpen.ShowNewFolderButton = ShowNewFolder10 nOpen.ShowDialog()11 Return nOpen.SelectedPath12 End Using13 End Function
效果图:
[VB.NET]调用系统的文件夹选择对话框
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。