I thought using application settings would do the trick but I’m not getting it to work. This is what I have:
private void btnBrowse_Click(object sender, EventArgs e)
{
if (fbFolderBrowser.ShowDialog() == DialogResult.OK)
{
// I want to open the last folder selected by the user here.
}
When the user clicks on this button, I want to open the browse window to the last folder he accessed and save it. Next time he clicks on the button, it’ll automatically select that folder.
I was thinking maybe I could use user variables where I can change at run-time but I’m not getting it to work. Can anyone give me a hand?
There are two places where you can find the last folder accessed by a user:
Recent Files and Folders: It can be found here:C:\Documents and Settings\USER\RecentRegistry: In the registry to look here:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRUYou can use this snippet to find it:
OR
In windows XP when you press Save on a
SaveFileDialogthe directory where the file is saved, is set as the new current working directory (the one inEnvironment.CurrentDirectory).In this way, when you reopen the
FileDialog, it is opened on the same directory as before.By setting
FileDialog.RestoreDirectory = true, when you close theFileDialogthe original working directory is restored.In Windows Vista/Seven the behavior is always as
FileDialog.RestoreDirectory = true.