I need the user to select a directory, not a file. How can I use Microsoft.Win32.OpenFileDialog (or any other component) to do that?
I'm using WPF4.0 in VisualStudio 2010 (.net 4.0)
use the 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 );
}
您可以通过Windows API代码包来访问Win32生态系统中的该对话框以及许多其他标准对话框和控件。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.