Is it possible to set FolderBrowserDialog.RootFolder to an arbitrary path from a string?

I'm trying to do it

FolderBrowserDialog dlg = new FolderBrowserDialog();
dlg.RootFolder = "C:\SomeUserSelectedFolder";

But RootFolderthere is System.Environment.SpecialFolder.

Does this mean that I can only install this in places like MyDocuments or Desktop?!?

+5
source share
1 answer

That's right: if the assigned value is RootFoldernot one of the values Environment.SpecialFolder, then an InvalidEnumArgumentException is thrown .

You can set SelectedPath though:

SelectedPath , , SelectedPath , RootFolder (, , , RootFolder).

+11

All Articles