Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9240719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:14:23+00:00 2026-06-18T08:14:23+00:00

As we know WPF OpenFileDialog no more changes the app’s working directory and RestoreDirectory

  • 0

As we know WPF OpenFileDialog no more changes the app’s working directory and RestoreDirectory property is “unimplemented”. However, upon subsequent open, its initial directory is default to the last opened file rather than the original working directory, so this information must be stored somewhere. I wonder is it possible to get/set it from user code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:14:24+00:00Added an answer on June 18, 2026 at 8:14 am

    On Windows 7 the recent file information is stored in the registry at this key:

    HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Comdlg32\OpenSaveMRU
    

    Beneath this key are subkeys for the various file extensions (e.g., exe, docx, py, etc).

    Now, if you want to read these values, this will get a list of all paths stored beneath the subkeys (adapted from here):

    String mru = @"Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSavePidlMRU";
    RegistryKey rk = Registry.CurrentUser.OpenSubKey(mru);
    List<string> filePaths = new List<string>();
    
    foreach (string skName in rk.GetSubKeyNames())
    {
        RegistryKey sk = rk.OpenSubKey(skName);
        object value = sk.GetValue("0");
        if (value == null)
            throw new NullReferenceException();
    
        byte[] data = (byte[])(value);
    
        IntPtr p = Marshal.AllocHGlobal(data.Length);
        Marshal.Copy(data, 0, p, data.Length);
    
        // get number of data;
        UInt32 cidl = (UInt32)Marshal.ReadInt16(p);
    
        // get parent folder
        UIntPtr parentpidl = (UIntPtr)((UInt32)p);
    
        StringBuilder path = new StringBuilder(256);
    
        SHGetPathFromIDListW(parentpidl, path);
    
        Marshal.Release(p);
    
        filePaths.Add(path.ToString());
    }
    

    References:

    • http://social.msdn.microsoft.com/Forums/zh/vcmfcatl/thread/bfd89fd3-8dc7-4661-9878-1d8a1bf62697
    • Getting the last opened file in fileopen dialog box
    • http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/c43ddefb-1274-4ceb-9cda-c78d860b687c)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know WPF is more complex an flexible so could be thought to do
Does anyone know a WPF control/app that functions like the google Finance graph/chart? Thank
I know WPF libraries aren´t implemented by mono class library, however(as far as I
How can a WPF app know if its getting remotely operated (via VNC or
I know that in WPF, FontSize = 1/96 of an inch (same as 1
I need to know when a WPF Datagrid has been sorted by the user.
What kind of skills should a WPF developer know to create MVVM applications? Things
In WPF, I know I can use ListView.ScrollIntoView to scroll a particular item into
As you know StringFormat is of great importance for data representation in WPF. My
Does anyone know the correct definition for a sliding window in WPF? What I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.