2020年5月25日 星期一

VB.NET 使用 FolderBrowserDialog 選路徑 [Use FolderBrowserDialog to select Path]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    Private Function SelectFolder() As String
        fbdSelect.SelectedPath = Application.StartupPath
        fbdSelect.ShowNewFolderButton = True
        fbdSelect.Description = "選擇資料夾"
        If fbdSelect.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Return fbdSelect.SelectedPath
        End If

        Return ""
    End Function





1
2
3
4
5
6
7
8
    Private Sub btnDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDir.Click
        FolderBrowserDialog1.SelectedPath = Application.StartupPath
        FolderBrowserDialog1.ShowNewFolderButton = True
        FolderBrowserDialog1.Description = "選擇資料夾"
        If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            TextBox1.Text = FolderBrowserDialog1.SelectedPath
        End If
    End Sub

沒有留言:

張貼留言