Vb.net - FolderBrowserDialog

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25260409/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 18:02:23  来源:igfitidea点击:

Vb.net - FolderBrowserDialog

vb.netfolderbrowserdialog

提问by N1C0

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

我遇到了一些麻烦,FolderBrowserDialog我已经尝试了所有我能在这里找到的帖子,就我想要的而言,我几乎就在那里。以下是我的代码:

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

回答by N1C0

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

Must be:

必须是:

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

回答by JohnnyQ

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

SelectedPath - 获取或设置用户选择的路径。

dialog.SelectedPath & "/helloforum.txt"

回答by Vivek S.

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

快乐编码