I am having trouble with a new .NET 5.0 application. I want to have a select folder dialog open, but I haven't found a class for that. All the code I find references the System.Windows.Forms library.
using (var dialog = new System.Windows.Forms.FolderBrowserDialog())
{
System.Windows.Forms.DialogResult result = dialog.ShowDialog();
}
What is the new way?
I didn't realize I needed to edit the .csproj file, nor did I know you could have both WPF and Windows Forms declared at the same time there. I kept thinking I needed to add it as a reference.
Modifying the project file in this way worked and allowed me to declare using System.Windows.Forms; without getting an error.
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows</TargetFramework>
<RootNamespace>WpfApp1_5</RootNamespace>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With