private void btnSelect2_Click(object sender, EventArgs e)
{
string path = GetPath();
if (!string.IsNullOrEmpty(path))
{
tbText2.Text = path;
}
}
private string GetPath()
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.Title = "选择文件";
fileDialog.Filter = "文本文件(*.txt)|*.txt|数据文件(*.dat)|*.dat|所有文件(*.*)|*.*";
fileDialog.FilterIndex = 1;
fileDialog.RestoreDirectory = true;
if (fileDialog.ShowDialog() == DialogResult.OK)
{
return fileDialog.FileName;
}
return string.Empty;
}