0

I want to show a Dialog where the user can select a folder.

MSDN features the following Snippet:

new System.Windows.Forms.FolderBrowserDialog();

Saying it lives in the following namespace and assembly:

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms.dll

I was unable to use the snippet because Forms does not exist in the System.Windows namespace. It was suggested that I am missing an assembly reference.

When I rightclick my project and choose Add->ProjectReference I see no references in the projects tab, none in the shared projects, none in Browse and a couple in COM. However, the closest I found was System_Windows_Forms which does not solve this problem.

How can I add the required resource to the project or how else can I display the required SelectFolder Dialog?

infinitezero
  • 1,610
  • 3
  • 14
  • 29
  • 1
    In your project settings (in Application/General) should be a "Enable Windows Forms" option you need to set. It just add "true" to your project file and should do the trick. – Ralf Jun 06 '23 at 11:24
  • Didn't find this anywhere, is it that obvious? This thankfully fixed it. Feel free to make it an answer. – infinitezero Jun 06 '23 at 11:28
  • Its not obvious. You might want to have a look at the version box in the help like in the page you linked. It does not state Net 7 and when you change to Net 7 it will state that the page not exists. When you get something else shown there like "Windows Desktop 7" like in this case you at least know here's something special going on even if the documentation fails about telling what that is. – Ralf Jun 06 '23 at 12:20

0 Answers0