OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string file = ofd.FileName; }
变量 file 就是最终拿到的文件路径和文件名称。