OpenFileDialog and the current directory

Just found out something odd that I never noticed before.  If you use the OpenFileDialog class to allow a user to select a file, then once they’ve selected a file, the directory that file is in is now your application’s current directory!  Huh?  Seems odd to me.

There’s an easy workaround.  The OpenFileDialog class has a RestoreDirectory property (actually, it comes from the base class FileDialog) which you can set to true to disable this quirky behavior.  Why it defaults to false is something I can’t answer…

1 Comment

Comments have been disabled for this content.