private void button1_Click(object sender, System.EventArgs e) { Stream myStream = null; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.InitialDirectory = "c:\\" ; openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ; openFileDialog1.FilterIndex = 2 ; openFileDialog1.RestoreDirectory = true ; if(openFileDialog1.ShowDialog() == DialogResult.OK) { try { if ((myStream = openFileDialog1.OpenFile()) != null) { using (myStream) { // Insert code to read the stream here. } } } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }
'C#.NET' 카테고리의 다른 글
[C#]사용자 아이피 알아오기 (0) | 2010.03.17 |
---|---|
[MSDN][BindingList] 데이터 바인드 개선 (0) | 2010.03.12 |
[Binding] 컨트롤 바인딩 할떄 포멧변경 (0) | 2010.03.11 |
Partial 클래스 (0) | 2010.03.10 |
errorProvider을 이용한 에러체크하기 (0) | 2010.03.09 |
[MSDN]DataGridView 셀에서 컨트롤 호스팅 (0) | 2010.03.03 |
[Interface]인터페이스가 구현되어져 있는지 확인해보기 (0) | 2010.03.03 |
[ErrorProvider]폼 유효성에 대한 오류 아이콘 표시 (0) | 2010.03.03 |
초간단 숫자 앞에 0 채우기 (0) | 2010.02.25 |
초간단 DataGridView 사용법 (추가중…) (0) | 2010.02.22 |