public void ButtonOpen_Click(object sender, EventArgs e)
{
OpenFileDialog fileDialog = new OpenFileDialog();
fileDialog.InitialDirectory="C:\\"; //打开对话框后的初始目录
fileDialog.Filter = "文本文件|*.txt|所有文件|*.*";
fileDialog.RestoreDirectory = false; //若为false,则打开对话框后为上次的目录。若为true,则为初始目录
if (fileDialog.ShowDialog() == DialogResult.OK)
FilePath.Text = System.IO.Path.GetFullPath(fileDialog.FileName);//将选中的文件的路径传递给TextBox “FilePath”
}