OpenFileDialog

Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
  dlg.FileName 
= "Document"// Default file name
  
  dlg.DefaultExt 
= ".txt"// Default file extension
  
  dlg.Filter 
= "Text documents (.txt)|*.txt"// Filter files by extension
  
  
  
// Show open file dialog box
  
  Nullable
<bool> result = dlg.ShowDialog();
  
  
// Process open file dialog box results
  
  
if (result == true)
  {
      
// Open document
  
      
string filename = dlg.FileName;
  }
原文地址:https://www.cnblogs.com/wpf123/p/2052882.html