//private static readonly Lazy<Dictionary<Environment.SpecialFolder, ShellAPI.CSIDL>> _shellFolderLookupDic = // new Lazy<Dictionary<Environment.SpecialFolder, ShellAPI.CSIDL>>(() => constructShellFolderLookupDic()); //private static readonly Lazy<Dictionary<Environment.SpecialFolder, string>> _directoryFullNameLookupDic = // new Lazy<Dictionary<Environment.SpecialFolder, string>>(() => constructDirectoryFullNameLookupDic()); //private static readonly Lazy<Dictionary<string, KnownFolder>> _pathToKnownFolderLookupDic = // new Lazy<Dictionary<string, KnownFolder>>(() => constructpathToKnownFolderLookupDic()); private static Dictionary <string, KnownFolder> constructpathToKnownFolderLookupDic() { Dictionary <string, KnownFolder> dic = new Dictionary <string, KnownFolder>(); foreach (var kfId in Enum.GetValues(typeof(KnownFolderIds))) { var category = EnumAttributeUtils <FolderCategoryAttribute, KnownFolderIds> .FindAttribute(kfId); if (category == null) { Debug.WriteLine(String.Format("Attribute {0} does not have FolderCategoryAttribute", kfId)); } else { if (category.Category != KnownFolderCategory.Virtual) { KnownFolder kf = KnownFolder.FromKnownFolderId((KnownFolderIds)kfId); string path = kf.Path; if (!dic.ContainsKey(path)) { dic.Add(path, kf); } } } } //foreach (var kf in KnownFolder.GetKnownFolders()) // if (kf.Category != KnownFolderCategory.Virtual) // { // string path = kf.Path; // if (path != null) // { // if (!dic.ContainsKey(path)) // dic.Add(path, kf); // } // } return(dic); }
public static KnownFolder FromKnownFolderId(KnownFolderIds kfId) { var guidAtb = EnumAttributeUtils <KnownFolderGuidAttribute, KnownFolderIds> .FindAttribute(kfId); return(FromKnownFolderId(guidAtb.Guid)); }
public DirectoryInfoEx(KnownFolderIds knownFolderId) : this(KnownFolder.FromKnownFolderId( EnumAttributeUtils <KnownFolderGuidAttribute, KnownFolderIds> .FindAttribute(knownFolderId).Guid)) { }