/// <summary> /// Creates actual extension association key in registry for the specified extension and supplied attributes. /// </summary> /// <param name="progId">Name of expected handling program.</param> /// <param name="perceivedType"><see cref="PerceivedTypes"/>PerceivedType of file type.</param> /// <param name="contentType">MIME type of file type.</param> /// <param name="openwithList"></param> /// <returns>FileAssociationInfo instance referring to specified extension.</returns> public FileAssociationInfo Create(string progId, PerceivedTypes perceivedType, string contentType, string[] openwithList) { FileAssociationInfo fai = new FileAssociationInfo(_extension); if (fai.Exists) { fai.Delete(); } fai.Create(); fai.ProgID = progId; if (perceivedType != PerceivedTypes.None) { fai.PerceivedType = perceivedType; } if (contentType != string.Empty) { fai.ContentType = contentType; } if (openwithList != null) { fai.OpenWithList = openwithList; } return(fai); }
/// <summary> /// Associates an already existing program id with a list of extensions. /// </summary> /// <param name="progId">The program id to associate extensions with.</param> /// <param name="extensions">String array of extensions to associate with program id.</param> public void Associate(string progId, params string[] extensions) { foreach (string s in extensions) { FileAssociationInfo fai = new FileAssociationInfo(s); if (!fai.Exists) { fai.Create(progId); } fai.ProgID = progId; } }
/// <summary> /// Associates a single executable with a list of extensions. /// </summary> /// <param name="progId">Name of program id</param> /// <param name="executablePath">Path to executable to start including arguments.</param> /// <param name="extensions">String array of extensions to associate with program id.</param> /// <example>progId = "MyTextFile" /// executablePath = "notepad.exe %1" /// extensions = ".txt", ".text"</example> public void Associate(string progId, string executablePath, params string[] extensions ) { foreach (string s in extensions) { FileAssociationInfo fai = new FileAssociationInfo(s); if (!fai.Exists) fai.Create(progId); fai.ProgID = progId; } ProgramAssociationInfo pai = new ProgramAssociationInfo(progId); if (!pai.Exists) pai.Create(); pai.AddVerb(new ProgramVerb("open", executablePath)); }
/// <summary> /// Associates a single executable with a list of extensions. /// </summary> /// <param name="progId">Name of program id</param> /// <param name="executablePath">Path to executable to start including arguments.</param> /// <param name="extensions">String array of extensions to associate with program id.</param> /// <example>progId = "MyTextFile" /// executablePath = "notepad.exe %1" /// extensions = ".txt", ".text"</example> public void Associate(string progId, string executablePath, params string[] extensions) { foreach (string s in extensions) { FileAssociationInfo fai = new FileAssociationInfo(s); if (!fai.Exists) { fai.Create(progId); } fai.ProgID = progId; } ProgramAssociationInfo pai = new ProgramAssociationInfo(progId); if (!pai.Exists) { pai.Create(); } pai.AddVerb(new ProgramVerb("open", executablePath)); }
/// <summary> /// Associates an already existing program id with a list of extensions. /// </summary> /// <param name="progId">The program id to associate extensions with.</param> /// <param name="extensions">String array of extensions to associate with program id.</param> public void Associate(string progId, params string[] extensions) { foreach (string s in extensions) { FileAssociationInfo fai = new FileAssociationInfo(s); if (!fai.Exists) fai.Create(progId); fai.ProgID = progId; } }
/// <summary> /// Creates actual extension association key in registry for the specified extension and supplied attributes. /// </summary> /// <param name="progId">Name of expected handling program.</param> /// <param name="perceivedType"><see cref="PerceivedTypes"/>PerceivedType of file type.</param> /// <param name="contentType">MIME type of file type.</param> /// <param name="openwithList"></param> /// <returns>FileAssociationInfo instance referring to specified extension.</returns> public FileAssociationInfo Create(string progId, PerceivedTypes perceivedType, string contentType, string[] openwithList) { FileAssociationInfo fai = new FileAssociationInfo(_extension); if (fai.Exists) { fai.Delete(); } fai.Create(); fai.ProgID = progId; if (perceivedType != PerceivedTypes.None) fai.PerceivedType = perceivedType; if (contentType != string.Empty) fai.ContentType = contentType; if (openwithList != null) fai.OpenWithList = openwithList; return fai; }
private static void RegisterFileType(string extensionType) { string id = "ilSFV-" + extensionType.ToUpper(); FileAssociationInfo fai = new FileAssociationInfo("." + extensionType.ToLower()); if (fai.Exists) fai.Delete(); fai.Create(id); string path = Assembly.GetExecutingAssembly().Location; ProgramAssociationInfo pai = new ProgramAssociationInfo(fai.ProgID); if (pai.Exists) pai.Delete(); pai.Create ( string.Format("{0} File", extensionType.ToUpper()), new ProgramVerb("Open", path + " \"%1\"") ); /*RegistryWrapper reg = new RegistryWrapper(); reg.Write(string.Format(@"{0}\shell\ilSFV", id), "MUIVerb", "ilSFV"); reg.Write(string.Format(@"{0}\shell\ilSFV", id), "MultiSelectModel", "Single"); reg.Write(string.Format(@"{0}\shell\ilSFV", id), "SubCommands", "ilsfv.verify");*/ }