public static FileAssociations GetAssociations() { FileAssociations assocs = new FileAssociations(); /////////////////////////////////////// String[] subkeyNames = Registry.ClassesRoot.GetSubKeyNames(); List <FileExtension> allExtensions = new List <FileExtension>(); Dictionary <String, List <FileExtension> > progIds = new Dictionary <String, List <FileExtension> >(); foreach (String keyName in subkeyNames) { if (!keyName.StartsWith(".", StringComparison.Ordinal)) { continue; } RegistryKey key = Registry.ClassesRoot.OpenSubKey(keyName); FileExtension ext = new FileExtension(assocs, key); allExtensions.Add(ext); if (ext.ProgId != null) { if (!progIds.ContainsKey(ext.ProgId)) { progIds.Add(ext.ProgId, new List <FileExtension>()); } progIds[ext.ProgId].Add(ext); } } /////////////////////////////////////// List <FileType> allTypes = new List <FileType>(); foreach (String keyName in progIds.Keys) { RegistryKey key = Registry.ClassesRoot.OpenSubKey(keyName); if (key == null) { continue; // then the extension uses its progid as its display name and that's it } FileType type = new FileType(assocs, key); type.Extensions.AddRange2(progIds[keyName]); foreach (FileExtension ext in type.Extensions) { ext.FileType = type; } allTypes.Add(type); } assocs._allExts = allExtensions; assocs._allTypes = allTypes; assocs.AllExtensions = new ReadOnlyCollection <FileExtension>(assocs._allExts); assocs.AllTypes = new ReadOnlyCollection <FileType> (assocs._allTypes); // Array.Sort( assocs.AllExtensions ); // Array.Sort( assocs.AllTypes ); return(assocs); }
internal FileExtension(FileAssociations assocs, RegistryKey key) : this(assocs) { LoadFromKey(key); }
internal FileExtension(FileAssociations assocs, String extension) : this(assocs) { Extension = extension; IsDirty = true; }
private FileExtension(FileAssociations assocs) : base(assocs) { OpenWithList = new Collection <String>(); OpenWithProgIds = new Collection <FileType>(); }
internal FileType(FileAssociations assocs, String progId) : this(assocs) { ProgId = progId; IsDirty = true; }
internal FileType(FileAssociations assocs, RegistryKey typeKey) : this(assocs) { LoadFromKey(typeKey); }
private FileType(FileAssociations assocs) : base(assocs) { Extensions = new Collection <FileExtension>(); ShellVerbs = new Dictionary <String, String>(); }
protected FileBase(FileAssociations assocs) { ParentAssocs = assocs; }