アプリケーション(拡張子exe)を選択させる
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
private void btnBrowseApp_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "title"; dlg.DefaultExt = "exe"; StringBuilder sbFilter = new StringBuilder(); sbFilter.Append("Application"); sbFilter.Append(" "); sbFilter.Append("(*"); sbFilter.Append(".exe"); sbFilter.Append(")|*"); sbFilter.Append(".exe"); sbFilter.Append("|"); sbFilter.Append("All Files (*.*)|*.*"); dlg.Filter = sbFilter.ToString(); if (DialogResult.OK != dlg.ShowDialog()) return; txtApp.Text = dlg.FileName; } } |
すべてのファイルから選択させる
1 2 3 4 5 6 7 8 9 10 11 |
private void btnBrowseArg_Click(object sender, EventArgs e) { using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.Title = "title"; if (DialogResult.OK != dlg.ShowDialog()) return; txtArg.Text = dlg.FileName; } } |