What does the FileDialog.RestoreDirectory Property actually do?

IIRC, in windows XP when you press Save on a SaveFileDialog (or Open on a OpenFileDialog) the directory where the file is saved (or opened), is set as the new current working directory (the one in Environment.CurrentDirectory).

By setting FileDialog.RestoreDirectory = true, when you close the FileDialog the original working directory is restored.

In Windows Vista/Seven the behavior is always as FileDialog.RestoreDirectory = true (yes, even if you set it to false...).


An annoyig quirk of the original implementation was that after you made your selection the current directory of your app changed to that folder, meaning that if you expected File operations to be relative to your app folder, it now failed.

This meant it was common practice to add code to capture the current folder before using he dialog, and restore it afterwards.

This was fixed, so it can do this for you, but changing the default behaviour might have broken code tha relied on the quirk. So you need to enable it manually via this property.