[2.0] Setting the initial directory of OpenFileDialog to the desktop
Hi everyone!
I trying to set the initial directory of the open file dialog to the desktop could anyone help me?
OpenFileDialog fdlg = new OpenFileDialog();
fdlg.InitialDirectory = @"c:\";
How do I set it to the desktop without doing something like this:
fdlg.InitialDirectory = @"C:\Documents and Settings\Jennifer\Desktop";
Jennifer.
Re: [2.0] Setting the initial directory of OpenFileDialog to the desktop
The System.Environment.GetFolderPath function will do what you need:
Code:
MessageBox.Show(System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
Re: [2.0] Setting the initial directory of OpenFileDialog to the desktop
Thanks, it worked - Jennifer