private void GoToFrbdkAssociation() { // We don't ask, we just do: FileAssociationManager.SetAllFileAssociations(); GoToEnd(); }
private void btnUoDoFileAssociate_Click(object sender, EventArgs e) { try { using (FileAssociationManager mgr = new FileAssociationManager()) { mgr.UnregisterApplicationAssociation(); } this.ShowMessage("已撤销文件关联"); } catch (Exception ex) { this.ShowMessage(ex.Message); } }
/// <summary> /// Простой пример работы функции /// </summary> /// <param name="fileName"></param> public void Execute(string fileName) { string title = Parser.Parse(fileName); FileAssociationManager associationManager = new FileAssociationManager(); //Временная заглушка (названия процесса) string processName = associationManager.GetAssociatedApplication(".pdf").Path; using (var context = new Model_PDFFinder()) { Report_Template printerSettings = Analizer.GetPrinterSettings(title, context); if (printerSettings != null) { Printer.Print(fileName, printerSettings); Logger.LogOpenForPrinting(title); } else { Viewer.View(fileName, processName); Logger.LogOpenForView(); } } }
private void btnDoFileAssociate_Click(object sender, EventArgs e) { try { using (FileAssociationManager mgr = new FileAssociationManager()) { foreach (object item in cListBoxFileExtension.CheckedItems) { using (ApplicationAssociation ext = mgr.RegisterFileAssociation(item.ToString())) { ext.DefaultIcon = new ApplicationIcon(Application.ExecutablePath); ext.ShellOpenCommand = Application.ExecutablePath; ext.Associated = true; } } } this.ShowMessage("已关联文件"); } catch (Exception ex) { this.ShowMessage(ex.Message); } }