文件目錄對話框的使用
文件對話框即過濾條件的使用:
string resultFile="";
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "D:\\Patch" ;
openFileDialog1.Filter = "All files (*.*)|*.*|txt files (*.txt)|*.txt" ;
openFileDialog1.FilterIndex = 2 ;
openFileDialog1.RestoreDirectory = true ;
if(openFileDialog1.ShowDialog() == DialogResult.OK)
resultFile=openFileDialog1.FileName;
目錄對話框的使用:
string resultFolder="";
FolderBrowserDialog openFolderDialog1=new FolderBrowserDialog();
openFolderDialog1.RootFolder=Environment.SpecialFolder.MyComputer;
if(openFolderDialog1.ShowDialog()==DialogResult.OK)
resultFolder=openFolderDialog1.SelectedPath;