RecentFilesRegistryHelper.cs
// Copyright 2012 ESRI // // All rights reserved under the copyright laws of the United States // and applicable international laws, treaties, and conventions. // // You may freely redistribute and use this sample code, with or // without modification, provided you include the original copyright // notice and use restrictions. // // See the use restrictions. // using System; using System.Collections.Generic; using System.Text; using ESRI.ArcGIS.Framework; using Microsoft.Win32; namespace RecentFilesCommandsCS { /// <summary> /// Helper class to process recent file lists stored in the registry /// </summary> class RecentFilesRegistryHelper { const string RecentFileRegistryKeyPath = @"Software\ESRI\{0}\Recent File List"; public static string[] GetRecentFiles(IApplication app) { List<string> recentFilePaths = new List<string>(); //Read the registry to get the recent file list string openKey = string.Format(RecentFileRegistryKeyPath, app.Name); RegistryKey recentListKey = Registry.CurrentUser.OpenSubKey(openKey); if (recentListKey != null) { string[] listNames = recentListKey.GetValueNames(); foreach (string name in listNames) { string fileName = recentListKey.GetValue(name, string.Empty).ToString(); if (!string.IsNullOrEmpty(fileName)) recentFilePaths.Add(fileName); } } return recentFilePaths.ToArray(); } } }