The system's built-in select folder control cannot manually enter the path selection.
Implementation
Search for the installation package in NuGet WindowsAPICodePack
, or directly open the Package Manager Console in VS and enter. Install-Package WindowsAPICodePack-Shell
After installation, add a reference and use it directly.
CommonOpenFileDialog ofd = new CommonOpenFileDialog();
ofd.IsFolderPicker = true; //设置为选择文件夹
if (ofd.ShowDialog() == CommonFileDialogResult.Ok)
{
MessageBox.Show(ofd.FileName);
}
The effect is as follows, you can manually enter the path selection