{"id":89,"date":"2011-10-18T19:44:12","date_gmt":"2011-10-18T21:44:12","guid":{"rendered":"http:\/\/blog.iordanov.info\/?p=89"},"modified":"2012-01-15T14:04:24","modified_gmt":"2012-01-15T16:04:24","slug":"view-the-list-of-recently-opened-files-in-windows","status":"publish","type":"post","link":"https:\/\/blog.iordanov.info\/?p=89","title":{"rendered":"View the list of recently opened files in Windows width C#"},"content":{"rendered":"<p>Each time that you open a file from Windows Explorer or from a standard open\/save dialog-box, the name of the file that you opened is recorded by the Windows operating system.<\/p>\n<p>Some of the names are saved into the &#8216;Recent&#8217; folder. Other are saved into the Registry.<\/p>\n<h3><a id=\"dnn_ctr734_MainView_ViewEntry_lblBlogTitle\">&#8220;Recent&#8221; Folder<\/a><\/h3>\n<p>The &#8220;Recent&#8221; folder is usually located under C:\\Documents and Settings\\[Your Profile]\\Recent (The path is different under Windows Vista), and it contains shortcuts to the recently opened files.<\/p>\n<p>Using <a title=\"Environment.SpecialFolder Enumeration\" href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/system.environment.specialfolder.aspx\">Environment.SpecialFolder Enumeration<\/a>\u00a0you can retrieve directory paths to system special folders as &#8220;Recent&#8221; folder\u00a0.<\/p>\n<h3><a id=\"dnn_ctr734_MainView_ViewEntry_lblBlogTitle\">Registry<\/a><\/h3>\n<p>Registry: If you are using open\/save dialog box for file selection, the selected file name is added to the files list under<\/p>\n<blockquote><p><span class=\"Apple-style-span\" style=\"line-height: 18px;\"> HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\OpenSaveMRU<\/span><\/p><\/blockquote>\n<p>The following method will give you an idea how to read saved data:<\/p>\n<pre>public static string GetRecentlyOpenedFile(string extention)\r\n{\r\n   RegistryKey regKey = Registry.CurrentUser;\r\n   string recentFile = string.Empty;\r\n   regKey = regKey.OpenSubKey(\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Explorer\\\\ComDlg32\\\\OpenSaveMRU\");\r\n\r\n   if (string.IsNullOrEmpty(extention))\r\n       extention = \"html\";\r\n\r\n   RegistryKey myKey = regKey.OpenSubKey(extention);\r\n\r\n   if (myKey == null &amp;&amp; regKey.GetSubKeyNames().Length &gt; 0)\r\n       myKey = regKey.OpenSubKey(\r\n                      regKey.GetSubKeyNames()[regKey.GetSubKeyNames().Length - 2]);\r\n   if (myKey != null)\r\n   {\r\n       string[] names = myKey.GetValueNames();\r\n       if (names != null &amp;&amp; names.Length &gt; 0)\r\n       {\r\n           recentFile = (string)myKey.GetValue(names[names.Length - 2]);\r\n       }\r\n    }\r\n    return recentFile;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Each time that you open a file from Windows Explorer or from a standard open\/save dialog-box, the name of the file that you opened is recorded by the Windows operating system. Some of the names are saved into the &#8216;Recent&#8217; &hellip;<\/p>\n<p class=\"read-more\"><a href=\"https:\/\/blog.iordanov.info\/?p=89\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":93,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5],"tags":[6,19,3,7,20],"class_list":["post-89","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dotnet","tag-net","tag-net-framework-4-0","tag-c-sharp","tag-c","tag-windows"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p3jsZJ-1r","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack_featured_media_url":"https:\/\/blog.iordanov.info\/wp-content\/uploads\/2011\/10\/a-Sunset-wave.jpg","_links":{"self":[{"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/posts\/89","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=89"}],"version-history":[{"count":8,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":95,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/posts\/89\/revisions\/95"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=\/wp\/v2\/media\/93"}],"wp:attachment":[{"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iordanov.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}