在Button1的Click事件里,添加下面的代码
OpenFileDialog dialog = new OpenFileDialog();
dialog.ShowDialog();
if (!string.IsNullOrEmpty(dialog.FileName))
{
button2.Text = dialog.FileName;
}
OpenFileDialog openFile = new OpenFileDialog();
if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
MessageBox.Show("文件路径:"+openFile.FileName+"文件名:"+openFile.SafeFileName);
}