C#的OpenFileDialog怎么用

2024-12-03 16:49:29
推荐回答(1个)
回答1:

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);}