How do I set the Initial Directory on an OpenFileDIalog to the users `Downloads` folder in C#
- by JMK
Ok so I have an OpenFileDialog and I want to set the initial directory to the users 'Download' folder. This is an internal application and, therefore, I am sure that the user will be using Windows 7.
var ofd = new OpenFileDialog();
//This doesn't work
ofd.InitialDirectory =
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Downloads");
//This doesn't work either
ofd.InitialDirectory = @"%USERPROFILE%\Downloads";
ofd.Filter = "Zip Files|*.zip";
ofd.ShowDialog();
txtFooBar.Text = ofd.FileName;
I have tried the above so far and neither work. No Exception is thrown, it just doesn't set the initial directory to the downloads folder.
Where am I going wrong?
Thanks