openFileDialog.RestoreDirectory doesn't work on XP RRS feed

  • Question

  • I am creating a new OpenFileDialog every time I prompt the user to open a file. The InitialDirectory property is set to MyDocuments and the RestoreDirectory property is set to true. When I run my application, every time the OpenFileDialog comes up it starts in MyDocuments, even after I have previously opened a file from a different location.

    Is there something inherently wrong with the OpenFileDialog? I am using the .net framework 3.5 on Windows XP. Thanks in advance.

    Thursday, April 1, 2010 7:35 PM


  • As documented in MSDN: http://msdn.microsoft.com/en-us/library/ms646839(VS.85).aspx  it doesn't work under NT/2000/XP.  But this flag doesn't impact the initial directory as displayed in the dialog.  The initial directory displayed in the dialog is controlled by the initial directory property (if set).  Normally when you use OFD to open a file the working directory for the app gets changed to the file's directory.  The aforementioned flag prevents that from occurring.  If the flag is used then the working directory before and after the dialog is displayed remains the same.

    Michael Taylor - 4/1/2010

    • Proposed as answer by JohnGrove Thursday, April 1, 2010 8:48 PM
    • Marked as answer by BBauer42 Friday, April 2, 2010 2:24 PM
    Thursday, April 1, 2010 8:10 PM