How do I get the Name of the current folder from my FileSave Dialog?

  • Thread starter Thread starter The Mad Ape
  • Start date Start date
T

The Mad Ape

Hello

I have a FileSave Dialog and am trying to pass the current folder name
to a string. Is there any way to do that? It was easy to get the file
path and name using .FileName but I see nothing to get the Folder.

Thanks

The Mad Ape


Dim RepDat As System.Windows.Forms.SaveFileDialog

RepDat = New System.Windows.Forms.SaveFileDialog()

RepDat.CreatePrompt = False
RepDat.OverwritePrompt = True
RepDat.FileName = lblFolder.Text

RepDat.Filter = "Access 2K (*.mdb) |*.mdb"

If RepDat.ShowDialog() = DialogResult.Cancel Then
Exit Sub
End If

Dim strFi As String = RepDat.FileName.ToString 'returns file
name

Dim strDir As String = 'what do I type here to get the current
folder?

RepDat.Dispose()
RepDat = Nothing
 
The said:
Hello

I have a FileSave Dialog and am trying to pass the current folder name
to a string. Is there any way to do that? It was easy to get the file
path and name using .FileName but I see nothing to get the Folder.

Thanks

The Mad Ape

Use the Path.GetDirectoryName method to get the path from the file name.
Dim RepDat As System.Windows.Forms.SaveFileDialog

RepDat = New System.Windows.Forms.SaveFileDialog()

RepDat.CreatePrompt = False
RepDat.OverwritePrompt = True
RepDat.FileName = lblFolder.Text

RepDat.Filter = "Access 2K (*.mdb) |*.mdb"

If RepDat.ShowDialog() = DialogResult.Cancel Then
Exit Sub

Oops! If you exit here, you don't dispose the dialog.
 
Back
Top