/// <summary> /// Verifica a instalacao do programa /// </summary> private static void VerificaInstalacao() { string asmName = Assembly.GetExecutingAssembly().Location; string location = Path.GetDirectoryName(asmName); Func <string, DirectoryInfo> criaDiretorio = new Func <string, DirectoryInfo>(s => (!Directory.Exists(Path.Combine(location, s))) ? Directory.CreateDirectory(Path.Combine(location, s)) : null); criaDiretorio("History"); criaDiretorio("Log"); try { FileAssociation FA = new FileAssociation(); FA.Extension = "kbd"; FA.ContentType = "application/kanbadaboard"; FA.FullName = "Quadro Kanban para Kanbada!"; FA.ProperName = "Kanbada! board"; FA.AddCommand("open", string.Format("\"{0}\" -view \"%1\"", asmName)); FA.IconPath = Path.Combine(location, @"Resources\kanbada.ico"); FA.Create(); // Remove the file type from the registry //FA.Remove(); } catch { // Se de erro nao precisa notificar usuario; } }
public void FileAssocTest() { FileAssociation assoc = new FileAssociation("sqlfoo"); assoc.DisplayName = "SQL Script"; assoc.ProperName = "sqlfooscript"; assoc.AddCommand("open", "C:\\River\\Orqa2\\Orqa\\bin\\debug\\orqa.exe %1"); assoc.Create(); }
public static void Associate() { string flashDevelopPath = Application.ExecutablePath; string codeBase = Assembly.GetExecutingAssembly().GetName().EscapedCodeBase; Uri uri = new Uri(codeBase); string dllPath = uri.LocalPath; string toolsDir = Path.Combine(Application.StartupPath, "tools"); string fdbuildDir = Path.Combine(toolsDir, "fdbuild"); string fdbuildPath = Path.Combine(fdbuildDir, "fdbuild.exe"); FileAssociation fa = new FileAssociation(); fa.Extension = "fdp"; fa.ContentType = "application/flashdevelopproject"; fa.FullName = "FlashDevelop Project file"; fa.ProperName = "FlashDevelop Project file"; fa.IconPath = dllPath; fa.IconIndex = 0; fa.AddCommand("open", "\"" + flashDevelopPath + "\" \"%1\""); fa.AddCommand("Compile with FDBuild", "\"" + fdbuildPath + "\" -pause \"%1\""); fa.Create(); }
private static void RegisterFileType() { try { FileAssociation FA = new FileAssociation(); FA.Extension = "stb"; FA.ContentType = "application/xml"; FA.FullName = "TreeDim StackBuilder Data Files"; FA.ProperName = "StackBuilder File"; FA.AddCommand("open", Assembly.GetExecutingAssembly().Location + " \"%1\""); FA.IconPath = Assembly.GetExecutingAssembly().Location; FA.IconIndex = 0; FA.Create(); } catch (Exception ex) { _log.Error(string.Format("File association failed! Exception : {0}", ex.Message)); } }
public static void CheckAssociation() { string ext = "auudb"; string logExt = RegConfig.Get <string>(ext); if (string.IsNullOrEmpty(logExt)) { string logIcon = Path.Combine(Application.StartupPath, "Uploader.Database.ico"); RegConfig.Set <string>(ext, logIcon); FileAssociation fa = new FileAssociation(); fa.Extension = ext; fa.ContentType = ""; fa.Description = "App Updates Database "; fa.ProgramId = Application.ProductName + "." + ext; fa.IconPath = logIcon; fa.AddCommand("open", Application.ExecutablePath + " %1"); fa.Create(); } }
/// <summary> /// This method checks whether the Registry is correctly setup to associate PP data files with the PP.exe app. /// If it isn't then it makes it so. /// Note: In the future we could make the Check more sophisticated to determine whether the Registry is already /// setup but simply pointing toward another application (like a future competitor of Pocket Pollster). /// Then we should ask whether to change the file association settings. /// </summary> private static void CheckFileAssociations() { FileAssociation FA = new FileAssociation(); FA.Extension = "pp"; FA.ContentType = "data/PocketPollster"; FA.FullName = "PocketPollster Data File"; FA.ProperName = "PocketPollster"; string path = Tools.EnsureFullPath(Application.StartupPath); // Points to the location of the executable FA.AddCommand("open", path + SysInfo.Data.Admin.AppFilename + " %1"); FA.IconPath = path + SysInfo.Data.Admin.AppFilename; FA.IconIndex = 0; if (FA.Check(path + SysInfo.Data.Admin.AppFilename + " %1") == false) { FA.Create(); } }
private void Btn_Register_Click(object sender, EventArgs e) { try { FileAssociation manageFileAssociation = new FileAssociation { Extension = "duck", ContentType = "text/plain", FullName = "Ducky Script File", ProperName = "Ducky Script", IconPath = Assembly.GetExecutingAssembly().Location, IconIndex = 0 }; manageFileAssociation.AddCommand("open", Assembly.GetExecutingAssembly().Location + " %1"); manageFileAssociation.Create(); MessageBox.Show(@"Registered file association to registry.", Application.ProductName); } catch (Exception exception) { MessageBox.Show(exception.Message, Application.ProductName); } }