/// <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); }
public static void RemoveAssociation(string extension) { var fai = new FileAssociationInfo(extension); if (fai.Exists) fai.Delete(); }
public static void RemoveAssociation(string extension) { var fai = new FileAssociationInfo(extension); if (fai.Exists) { fai.Delete(); } }
/// <summary> /// Creates actual file extension entry in registry. /// </summary> /// <param name="file"><see cref="FileAssociationInfo"/> instance that contains specifics on extension to be created.</param> protected void Create(FileAssociationInfo file) { if (file.Exists) { file.Delete(); } RegistryKey root = Registry.ClassesRoot; root.CreateSubKey(file.extension); }
private void buttonOK_Click(object sender, EventArgs e) { TRE_Explorer.Properties.Settings.Default.OpenFolder = this.textBoxOpenFolder.Text; TRE_Explorer.Properties.Settings.Default.SaveFolder = this.textBoxSaveFolder.Text; switch (this.comboBoxDefaultView.SelectedItem.ToString()) { case "Large Icons": TRE_Explorer.Properties.Settings.Default.DefaultView = View.LargeIcon; break; case "Small Icons": TRE_Explorer.Properties.Settings.Default.DefaultView = View.SmallIcon; break; case "List": TRE_Explorer.Properties.Settings.Default.DefaultView = View.List; break; case "Details": TRE_Explorer.Properties.Settings.Default.DefaultView = View.Details; break; } TRE_Explorer.Properties.Settings.Default.DetailsDisplaysFullPath = this.checkBoxDetailsPanePathDisplay.Checked; TRE_Explorer.Properties.Settings.Default.PromptForUpdates = this.checkBoxPromptForUpdates.Checked; TRE_Explorer.Properties.Settings.Default.DisplayNotifyIcon = this.checkBoxDisplayNotifyIcon.Checked; TRE_Explorer.Properties.Settings.Default.Save(); for (Int32 index = 0; index < this.checkedListBoxFileTypes.Items.Count; index++) { FileAssociationInfo fileAssociationInfo = new FileAssociationInfo("." + this.checkedListBoxFileTypes.Items[index].ToString().ToLower()); if (this.checkedListBoxFileTypes.GetItemChecked(index)) { if (!fileAssociationInfo.Exists) { fileAssociationInfo.Create("TRE Explorer"); } else { fileAssociationInfo.ProgID = "TRE Explorer"; } } else { if ((fileAssociationInfo.Exists) && (fileAssociationInfo.ProgID == "TRE Explorer")) { fileAssociationInfo.Delete(); } } } this.DialogResult = DialogResult.OK; }
/// <summary> /// Creates actual file extension entry in registry. /// </summary> /// <param name="file"><see cref="FileAssociationInfo"/> instance that contains specifics on extension to be created.</param> protected void Create(FileAssociationInfo file) { if (file.Exists) { file.Delete(); } RegistryKey root = Registry.ClassesRoot; root.CreateSubKey(file.extension); }
/// <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 void torrentAssociationCheckBoxChecked(object sender, RoutedEventArgs e) { var torrent = new FileAssociationInfo(".torrent"); if (torrentAssociationCheckBox.IsChecked.Value) { torrent.Create("Patchy"); torrent.ContentType = "application/x-bittorrent"; torrent.OpenWithList = new[] { "patchy.exe" }; var program = new ProgramAssociationInfo(torrent.ProgID); if (!program.Exists) { program.Create("Patchy Torrent File", new ProgramVerb("Open", string.Format( "\"{0}\" \"%1\"", Path.Combine(Assembly.GetEntryAssembly().Location)))); program.DefaultIcon = new ProgramIcon(Assembly.GetEntryAssembly().Location); } } else torrent.Delete(); }
public static void RegisterFileAssociation() { FileAssociationInfo fileInfo = new FileAssociationInfo(".cin"); if (fileInfo.Exists) fileInfo.Delete(); if (!fileInfo.Exists) { fileInfo.Create("YahooKeyKeyCin"); fileInfo.ContentType = "text/plain"; fileInfo.OpenWithList = new string[] { "CinInstaller.exe", "notepad.exe", "winword.exe" }; } string currentLocale = CultureInfo.CurrentUICulture.Name; ProgramAssociationInfo programInfo = new ProgramAssociationInfo(fileInfo.ProgID); if (programInfo.Exists) programInfo.Delete(); if (!programInfo.Exists) { string cinInstallerFilename = Application.StartupPath + Path.DirectorySeparatorChar + "CinInstaller.exe"; string command = cinInstallerFilename + " %1"; string description = "Yahoo! KeyKey Input Method Table"; if (currentLocale.Equals("zh-TW")) description = "Yahoo! \u5947\u6469\u8f38\u5165\u6cd5\u8868\u683c"; else if (currentLocale.Equals("zh-CN")) description = "Yahoo! \u5947\u6469\u8f93\u5165\u6cd5\u8868\u683c"; programInfo.Create(description, new ProgramVerb("Open", @command)); programInfo.DefaultIcon = new ProgramIcon(cinInstallerFilename, 1); programInfo.AlwaysShowExtension = true; } ProgramAssociationInfo uriInfo = new ProgramAssociationInfo("ykeykey"); if (uriInfo.Exists) uriInfo.Delete(); if (!uriInfo.Exists) { string urlHandlerFilename = Application.StartupPath + Path.DirectorySeparatorChar + "PhraseEditor.exe"; string command = urlHandlerFilename + " %1"; string description = "URL:Yahoo! KeyKey User Phrase Protocol"; if (currentLocale.Equals("zh-TW")) description = "URL:Yahoo! \u5947\u6469\u8f38\u5165\u6cd5\u52a0\u5b57\u52a0\u8a5e\u5354\u5b9a"; else if (currentLocale.Equals("zh-CN")) description = "URL:Yahoo! \u5947\u6469\u8f93\u5165\u6cd5\u52a0\u5b57\u52a0\u8bcd\u534f\u5b9a"; uriInfo.Create(description, new ProgramVerb("Open", @command)); // uriInfo.DefaultIcon = new ProgramIcon(urlHandlerFilename, 1); uriInfo.IsURLProtocol = true; } }