private void BtnSelectTxtFile_Click(object sender, EventArgs e) { if (DlgSelectText.ShowDialog() == DialogResult.OK) { try { var filePath = DlgSelectText.FileName; using (FileStream fs = File.Open(filePath, FileMode.Open)) // 따로 close 하지 않아도 됨 { Process.Start("notepad.exe", filePath); //Process.Start(@"C:\Program Files (x86)\Notepad++\notepad++.exe", filePath); // 경로에 띄어쓰기 인식 못함 } } catch (SecurityException ex) { // 보안상 권한 제한이 있는 곳 알림 MessageBox.Show($"{ex.Message}"); } catch (Exception ex) { MessageBox.Show($"{ex.Message}"); } } }
private void BtnSelectFile_Click(object sender, EventArgs e) { if (DlgSelectText.ShowDialog() == DialogResult.OK) { try { var filePath = DlgSelectText.FileName; using (FileStream fs = File.Open(filePath, FileMode.Open)) { Process.Start(@"C:\DEV\Notepad++\notepad++.exe", filePath); } } catch (SecurityException ex) { MessageBox.Show($"{ ex.Message}"); } } }
private void button1_Click(object sender, EventArgs e) { if (DlgSelectText.ShowDialog() == DialogResult.OK) { try { var filePath = DlgSelectText.FileName; using (FileStream fs = File.Open(filePath, FileMode.Open)) { Process.Start("notepad.exe", filePath); } } catch (SecurityException SE) { throw; } } }
private void BtnSelectFile_Click(object sender, EventArgs e) { if (DlgSelectText.ShowDialog() == DialogResult.OK) { try { var filePath = DlgSelectText.FileName; using (FileStream fs = File.Open(filePath, FileMode.Open)) { Process.Start("notepad.exe", filePath); // C/windows/notepad.exe 를 호출 // Process.Start(@"C:\Program Files\Notepad++\notepad++.exe", filePath); // notepad++ 호출 // 파일을 호출할때 파일명이 스페이스바(공백)이 있으면 호출되지 않는다. } } catch (SecurityException ex) { MessageBox.Show($"{ex.Message}"); } } }