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(); }
/// <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; } }