using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; namespace test1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "所有文件|*.*"; //还原当前目录 openFileDialog.FilterIndex = 1; if (openFileDialog.ShowDialog() == DialogResult.OK) { string path = openFileDialog.FileName; } } } }