// 获取文件夹绝对路径 显示在 txtbox 控件里
System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog();
if (folder.ShowDialog() == DialogResult.OK){
this.txtboxPath.Text = folder.SelectedPath;
}
// 获取文件和路径名 一起显示在 txtbox 控件里
OpenFileDialog dialog = new OpenFileDialog();if (dialog .ShowDialog() == DialogResult.OK)
{
this.txtboxPath.SelectedText = dialog.FileName;
}
//如果只显示文件名
OpenFileDialog dialog = new OpenFileDialog();
if (dialog .ShowDialog() == DialogResult.OK)
{
this.txtboxPath.SelectedText = dialog.SafeFileName;
}