【问题标题】:Vb.net - FolderBrowserDialogVb.net - 文件夹浏览器对话框
【发布时间】:2014-08-12 09:12:21
【问题描述】:

我在使用 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

会给我这样的东西:

System.Windows.Forms.FolderBrowserDialog/helloforum.txt

我希望它给它的地方例如:

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

【问题讨论】:

  • helloforum.txt 是否总是从您的application.startupPath 中获取信息??
  • 是的,它对我有用 :)
  • 如果是这样,那么你不需要使用这个Dim dialog = New FolderBrowserDialog() 而不是这个你可以获得像textBoxShowOutput.Text = Application.StartupPath & "/helloforum.txt"这样的文件名

标签: vb.net folderbrowserdialog


【解决方案1】:
TextBoxShowOutput.Text = dialog.ToString & "/helloforum" & ".txt"

必须是:

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

【讨论】:

    【解决方案2】:

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

    dialog.SelectedPath & "/helloforum.txt"
    

    【讨论】:

      【解决方案3】:

      仅供参考

      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
      

      快乐编码

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-11-18
        • 2012-10-29
        • 1970-01-01
        • 2011-03-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多