Can SaveFileDialog1 return folder?

  • Thread starter Thread starter Robert Liles
  • Start date Start date
R

Robert Liles

I want a dialog like SaveFileDialog1 that returns a folder (aka path)
instead of a file name. I have a program that has a file with a file name
already assigned, but I want to allow the user to select the directory to
store it in. Is this possible with a supplied dialog or do I have to create
my own dialog?

Thank you,

Bobbo
 
I sometimes prefer this dialog instead of the BrowseForFolder, because it
lets you see the files.

Just put whatever you want in the .FileName property, something like "Choose
your folder".
Make shure to set .CheckFileExists = False
Then, extract the pathname from the returned .FileName.

Dim pathname As String
With Me.OpenFileDialog1
.CheckFileExists = False
.CheckPathExists = True
.FileName = "Choose your folder"
If .ShowDialog() = DialogResult.OK Then
pathname = System.IO.Path.GetDirectoryName(.FileName)
End If
End With

Best Regards,
Alejandro Lapeyre
 

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

Back
Top