Basically you need the FolderBrowserDialog
class:
Prompts the user to select a folder. This class cannot be inherited.
Example:
using(var fbd = new FolderBrowserDialog())
{
DialogResult result = fbd.ShowDialog();
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(fbd.SelectedPath))
{
string[] files = Directory.GetFiles(fbd.SelectedPath);
System.Windows.Forms.MessageBox.Show("Files found: " + files.Length.ToString(), "Message");
}
}
If you work in WPF you have to add the reference to System.Windows.Forms
.
you also have to add using System.IO
for Directory
class
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…