OpenFileDialog openFileDialog=new OpenFileDialog();openFileDialog.InitialDirectory="c:\\";openFileDialog.Filter="文本文件|*.*|C#文件|*.cs|所有文件|*.*";openFileDialog.RestoreDirectory=true;openFileDialog.FilterIndex=1;if (openFileDialog.ShowDialog()==DialogResult.OK){ MessageBox.Show(openFileDialog.FileName);}