Set InitialDirectory to User's Documents Folder

R

Randy

I'm setting up a SaveAs form and I'd like to have the initial
directory default to the user's documents folder. Since I don't know
what drive that will be be on, etc., I'm wondering how to set this
up. Here is my code:

Dim FileDialogControl As New SaveFileDialog
FileDialogControl.FileName = "myfile.doc"
FileDialogControl.InitialDirectory = "C:\" 'THIS IS THE
LINE THAT I AM WONDERING ABOUT
FileDialogControl.Title = "Save File"
FileDialogControl.ShowDialog()


Can anybody help?
Thanks,
Randy
 
T

Tom Shelton

I'm setting up a SaveAs form and I'd like to have the initial
directory default to the user's documents folder. Since I don't know
what drive that will be be on, etc., I'm wondering how to set this
up. Here is my code:

Dim FileDialogControl As New SaveFileDialog
FileDialogControl.FileName = "myfile.doc"
FileDialogControl.InitialDirectory = "C:\" 'THIS IS THE
LINE THAT I AM WONDERING ABOUT
FileDialogControl.Title = "Save File"
FileDialogControl.ShowDialog()

Can anybody help?
Thanks,
Randy

FileDialogControl.InitialDirectory =
System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
 

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