private void button1_Click(object sender, EventArgs e)
{
//OpenFileDialog dlg = new OpenFileDialog();
OpenFileDialog fileDialog1 = new OpenFileDialog();
fileDialog1.InitialDirectory = "d:\";//初始目录
fileDialog1.Filter = "Text Files (.txt)|*.txt|All Files (*.*)|*.*";//文件的类型
fileDialog1.FilterIndex = 1;
fileDialog1.RestoreDirectory = true;
if (fileDialog1.ShowDialog() == DialogResult.OK)
{
textBox1.Text = fileDialog1.FileName;
}
else
{
textBox1.Text = "";
}
}