我需要用户选择目录,而不是文件.我如何使用Microsoft.Win32.OpenFileDialog(或任何其他组件)来做到这一点?
我在VisualStudio 2010中使用WPF4.0(.net 4.0)
最佳答案 使用System.
Windows.Forms.FolderBrowserDialog:
var dlg = new System.Windows.Forms.FolderBrowserDialog();
dlg.ShowNewFolderButton = true; //if you want new folders as well
dlg.SelectedPath = someStartPath; //where to start
if( dlg.ShowDialog() == DialogResult.OK )
{
//ok user selected something
DoStuffWith( dlg.SelectedPath );
}