C# custom select folder, you can manually enter the path

The system's built-in select folder control cannot manually enter the path selection.
system build-in

Implementation

Search for the installation package in NuGet WindowsAPICodePack, or directly open the Package Manager Console in VS and enter. Install-Package WindowsAPICodePack-Shell
NuGet
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
Insert image description here

Guess you like

Origin blog.csdn.net/qq_29242649/article/details/127611412