Vb.net - FolderBrowserDialog

谁说我不能喝 提交于 2019-12-13 02:26:38

问题


I am having some troubles with FolderBrowserDialog I've tried all the post I could find here and I'm almost there in terms of what I want. following is my code:

Private Sub ButtonBrowseOutput_Click(sender As Object, e As EventArgs) Handles ButtonBrowseOutput.Click
    Dim dialog = New FolderBrowserDialog()
    dialog.SelectedPath = Application.StartupPath
    If DialogResult.OK = dialog.ShowDialog() Then
        TextBoxShowOutput.Text = dialog.ToString & "/helloforum" & ".txt"
    End If
End Sub

would give me something like this:

System.Windows.Forms.FolderBrowserDialog/helloforum.txt

Where I want it to give it for example:

c:/users/sexyname/desktop/helloforum.txt

回答1:


TextBoxShowOutput.Text = dialog.ToString & "/helloforum" & ".txt"

Must be:

TextBoxShowOutput.Text = dialog.SelectedPath & "/helloforum" & ".txt"



回答2:


SelectedPath - Gets or sets the path selected by the user.

dialog.SelectedPath & "/helloforum.txt"



回答3:


Just for your knowledge

Private Sub AbsolutePathOfDialogBoxes()
    Dim dlgFolder = New FolderBrowserDialog
    Dim dlgOpenFile = New OpenFileDialog
    Dim dlgSaveFile = New SaveFileDialog
    Dim absolutePath As String
    '/*-----------------------------------*/'
    absolutePath = dlgFolder.SelectedPath
    absolutePath = dlgOpenFile.FileName
    absolutePath = dlgSaveFile.FileName
    '/*-----------------------------------*/'
End Sub

Happy Coding



来源:https://stackoverflow.com/questions/25260409/vb-net-folderbrowserdialog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!