WPF 获得文件夹路径可用FolderBrowserDialog类,
添加System.Windows.Forms引用,
并引用命名空间using System.Windows.Forms;
View Code
1 private void button1_Click(object sender, RoutedEventArgs e)
2 {
3 FolderBrowserDialog fbd = new FolderBrowserDialog();
4 fbd.Description = "pls select a folder";
5 if(fbd.ShowDialog() == DialogResult.OK)
6 {
7 textBox1.Text = fbd.SelectedPath;
8 }
9 }