当前位置:网站首页>WPF select Folder

WPF select Folder

2022-06-21 22:34:00 zLulus

The effect is as shown in the picture
20201214_154224

Use FolderBrowserDialog

System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
System.Windows.Forms.DialogResult result = dialog.ShowDialog();

if (result == System.Windows.Forms.DialogResult.Cancel)
{
    return;
}
selectFolrderPathTextBlock.Text = dialog.SelectedPath.Trim();

Use FolderBrowserDialog

// quote WindowsAPICodePack
var dialog = new CommonOpenFileDialog();
dialog.IsFolderPicker = true;
CommonFileDialogResult result = dialog.ShowDialog();
if (result == CommonFileDialogResult.Ok)
{
    selectFolrderPathTextBlock.Text = dialog.FileName;
}

Sample code

SelectFolder

Reference material

OpenFileDialog In WPF
C# OPENFILEDIALOG Open the file dialog ( Detailed explanation )

原网站

版权声明
本文为[zLulus]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206212041018717.html