码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2014-09-07 13:25:05      阅读:329      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   io   ar   for   文件   

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

1     Private Function SelectFolder(ByVal Describe As String, Optional ByVal ShowNewFolder As Boolean = True) As String
2         Using nOpen As New System.Windows.Forms.FolderBrowserDialog()
3             nOpen.Description = Describe
4             nOpen.ShowNewFolderButton = ShowNewFolder
5             nOpen.ShowDialog()
6             Return nOpen.SelectedPath
7         End Using
8     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 = ShowNewFolder
10             nOpen.ShowDialog()
11             Return nOpen.SelectedPath
12         End Using
13     End Function

效果图:

bubuko.com,布布扣

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

标签:des   style   blog   http   color   io   ar   for   文件   

原文地址:http://www.cnblogs.com/sunsoftresearch/p/3960297.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!