Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opening a directory chooser in C#

Tags:

I am writing a quick and dirty application that reads all the files from a given directory. I'm currently using the OpenFileDialog to choose a directory and just culling off the file name that it provides. It seems like there should be a way to just choose directories though, but in a quick browsing of MSDN I didn't find it.

If you have a way in winforms or more preferably in WPF I'm all ears.

like image 980
Dan Blair Avatar asked Nov 12 '08 17:11

Dan Blair


2 Answers

You'll want to use a FolderBrowserDialog.

like image 145
Kibbee Avatar answered Oct 13 '22 15:10

Kibbee


using FORMS = System.Windows.Forms;  var dialog = new System.Windows.Forms.FolderBrowserDialog(); FORMS.DialogResult result = dialog.ShowDialog(); if (result == FORMS.DialogResult.OK) {     MessageBox.Show("Result: " + dialog.SelectedPath); } 
like image 31
Geoff Avatar answered Oct 13 '22 15:10

Geoff