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;
}
}

 

 

+ Recent posts