首页 > 代码库 > WPF 浏览文件夹,获取其路径

WPF 浏览文件夹,获取其路径

        public void GetPath(System.Windows.Controls.TextBox TB)        {            FolderBrowserDialog FBD = new FolderBrowserDialog();            FBD.Description = "请选择一个路径";            if(FBD.ShowDialog()==System.Windows.Forms.DialogResult.OK)            {                TB.Text = FBD.SelectedPath;            }        }
获取路径代码
        private void btnOrg_Click(object sender, RoutedEventArgs e)        {            GetPath(txtOrgpath);        }
调用代码

效果图

注意:需要添加Winform引用:using System.Windows.Forms;