『QQ:1353814576』

wpf调用文件目录选择对话框


wpf实现调用文件目录选择对话框

//调取文件选区对话框
Microsoft.Win32.OpenFileDialog ofd = new Microsoft.Win32.OpenFileDialog(); 
ofd.DefaultExt = ".txt"; 
ofd.Filter = "text file|*.txt"; 
if (ofd.ShowDialog() == true) 
{ 
     //ofd.FileName; 
}
//调取文件夹对话框
//使用System.Windows.Forms命名空间下的FolderBrowserDialog类
FolderBrowserDialog Dialog = new FolderBrowserDialog();
DialogResult result = Dialog.ShowDialog();
 
if (result == System.Windows.Forms.DialogResult.Cancel)
{
     return;
}
string Path = m_Dialog.SelectedPath;