OpenFileDlg Class가 있어서,
그냥 선언 후 사용하면 OpenDialog Box를 생성시킬 수 있다.
1. Button을 클릭했을때, OpenFileDialog를 만들어 보자.
/// function history
/// FuncName: btnOpenFile_Click
/// review : This function is execute the Open File Dialog
/// apply : Open File Dialog method.
private void btnOpenFile_Click(object sender, EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Title = "Open Summary files...";
dlg.InitialDirectory = @"c:\FROM30";
dlg.Filter = "Summary files(*.dat)|*.dat|All Files|*.*";
if (dlg.ShowDialog() == DialogResult.OK)
{
string strFilePath = dlg.FileName;
txtSummaryPath.Text = strFilePath;
m_bOpenfile = true;
}else
m_bOpenfile = false;
this.btnSummaryView_Click(sender, e);
}
추가로 폴더만 선택하고 싶다면..
FolerBrowserDialog를 사용할것..
// 요렇게..
private void btnRFilePath_Click(object sender, EventArgs e)
{
FolderBrowserDialog fDlg = new FolderBrowserDialog();
fDlg.ShowNewFolderButton = true;
fDlg.SelectedPath = @"c:\From30"; //초기값설정.
if (fDlg.ShowDialog() == DialogResult.OK)
{
txtboxResultFilePath.Text = fDlg.SelectedPath;
}
}
'프로그래밍 > .Net' 카테고리의 다른 글
To execut the another Form(form dialog를 띄워보자) (0) | 2014.01.17 |
---|---|
file access, file을 생성하고 읽어보자 (0) | 2014.01.17 |
SourceGrid2 사용하기 (0) | 2014.01.17 |
버튼에 이미지를 넣어서 마우스 포인트 이동시 변환되도록 (0) | 2014.01.17 |
c#에서 윈도우 메세지 보내기.. - 발췌 (0) | 2014.01.17 |