Пример #1
0
 //デフォルトのブラウザの取得
 private string GetDefaultBrowser() {
     RegistryManager reg = new RegistryManager();
     return reg.GetApplicationFullPathByExtension(".html");
 }
Пример #2
0
        //外部ファイルの呼び出し
        private void CallWindow(int row_index) {
            string f_name = ds_main.Tables["Task"].Rows[row_index][3].ToString();
            string strTaskPath = env_data.Project.Folder + env_data.Project.SelectedFolder + @"\";
            string app_name;
            string ext;
            Process p;
            if (f_name.Length == 0) {
                Random rnd = new Random();
                string rnd_str = rnd.Next(100).ToString("D2");
                f_name = DateTime.Now.ToString("yyyyMMddhhmmss") +rnd_str + ".txt";
                if (!File.Exists(strTaskPath + f_name)) {
                    StreamWriter sw = File.CreateText(strTaskPath + f_name);
                    sw.Close();

                }
                ds_main.Tables["Task"].Rows[row_index][3] = f_name;
                SaveData();
            }
            if (!File.Exists(strTaskPath + f_name)) {
                if (Path.GetExtension(f_name) == ".txt" || Path.GetExtension(f_name) == ".csv" || Path.GetExtension(f_name) == ".xml")
                    File.Create(strTaskPath + f_name);
                else {
                    MessageBox.Show("ファイルが見つかりません", "エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            ext = Path.GetExtension(f_name);
            if (ext == ".txt" && env_data.Documents.Editor.Length > 5) {
                app_name = env_data.Documents.Editor;
            } else {
                RegistryManager reg = new RegistryManager();
                app_name = reg.GetApplicationFullPathByExtension(ext);
                if (app_name == "") {
                    app_name = reg.GetApplicationFileByExtension(ext);
                    if (app_name == "") {
                        try {
                            p = Process.Start(strTaskPath + f_name);
                        } catch (Exception ex) {
                            throw new Exception(ex.Message);
                        }
                        return;
                    }
                }
            }
            
            try {
                p = Process.Start(app_name, strTaskPath + f_name);
            } catch (Exception ex) {
                try {
                    p = Process.Start(strTaskPath + f_name);
                } catch {
                    throw ex;
                }
            }
        }