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

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
 
G

Göran Andersson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top