Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two places where you can find the last folder accessed by a user:</p> <ol> <li><code>Recent Files and Folders</code>: It can be found here: <code>C:\Documents and Settings\USER\Recent</code></li> <li><code>Registry</code>: In the registry to look here: <code>HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU</code></li> </ol> <p>You can use this snippet to find it:</p> <pre><code>public static string GetLastOpenSaveFile(string extention) { RegistryKey regKey = Registry.CurrentUser; string lastUsedFolder = string.Empty; regKey = regKey.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\OpenSaveMRU"); if (string.IsNullOrEmpty(extention)) extention = "html"; RegistryKey myKey = regKey.OpenSubKey(extention); if (myKey == null &amp;&amp; regKey.GetSubKeyNames().Length &gt; 0) myKey = regKey.OpenSubKey(regKey.GetSubKeyNames()[regKey.GetSubKeyNames().Length - 2]); if (myKey != null) { string[] names = myKey.GetValueNames(); if (names != null &amp;&amp; names.Length &gt; 0) { lastUsedFolder = (string)myKey.GetValue(names[names.Length - 2]); } } return lastUsedFolder; } </code></pre> <p>OR</p> <p>In windows XP when you press Save on a <code>SaveFileDialog</code> the directory where the file is saved, is set as the new current working directory (the one in <code>Environment.CurrentDirectory</code>).</p> <p>In this way, when you reopen the <code>FileDialog</code>, it is opened on the same directory as before.</p> <p>By setting <code>FileDialog.RestoreDirectory = true</code>, when you close the <code>FileDialog</code> the original working directory is restored.</p> <p>In Windows Vista/Seven the behavior is always as <code>FileDialog.RestoreDirectory = true</code>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload