[VB.NET]调用系统的文件夹选择对话框

以下示例代码展示如何调用系统的文件夹选择对话框:

     Private Function SelectFolder(ByVal Describe As String, Optional ByVal ShowNewFolder As Boolean = True) As String
Using nOpen As New System.Windows.Forms.FolderBrowserDialog()
nOpen.Description = Describe
nOpen.ShowNewFolderButton = ShowNewFolder
nOpen.ShowDialog()
Return nOpen.SelectedPath
End Using
End Function

调用方式:

     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim _selectedFolder As String = SelectFolder("请选择安装目录", True) '显示选择安装目录界面,同时允许创建新文件夹
MsgBox(_selectedFolder)
End Sub Private Function SelectFolder(ByVal Describe As String, Optional ByVal ShowNewFolder As Boolean = True) As String
Using nOpen As New System.Windows.Forms.FolderBrowserDialog()
nOpen.Description = Describe
nOpen.ShowNewFolderButton = ShowNewFolder
nOpen.ShowDialog()
Return nOpen.SelectedPath
End Using
End Function

效果图:

[VB.NET]调用系统的文件夹选择对话框

上一篇:#Java学习之路——基础阶段(第十一篇)


下一篇:Impala:新一代开源大数据分析引擎--转载