2

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
Vivek S.
  • 19,945
  • 7
  • 68
  • 85
  • does `helloforum.txt` always taking from your `application.startupPath` ?? – Vivek S. Aug 12 '14 at 11:14
  • yes it does for me :) –  Aug 12 '14 at 11:26
  • if so then you need not to use this `Dim dialog = New FolderBrowserDialog()` instead of this you could get the file name like `textBoxShowOutput.Text = Application.StartupPath & "/helloforum.txt"` – Vivek S. Aug 12 '14 at 11:31

3 Answers3

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

Must be:

TextBoxShowOutput.Text = dialog.SelectedPath & "/helloforum" & ".txt"
N1C0
  • 121
  • 4
1

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

dialog.SelectedPath & "/helloforum.txt"
JohnnyQ
  • 1,591
  • 1
  • 16
  • 25
1

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

Vivek S.
  • 19,945
  • 7
  • 68
  • 85