In wpf, how can I use the standard dialog to select a directory

I need a user to select a directory, not a file. How can I use Microsoft.Win32.OpenFileDialog (or any other component) for this?

I am using WPF4.0 in VisualStudio 2010 (.net 4.0)

+4
source share
2 answers

use 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 ); } 
+2
source

You have access to this and many other standard dialog boxes and controls from the Win32 ecosystem through the Windows Code Code Pack .

0
source

Source: https://habr.com/ru/post/1380376/


All Articles