Choosing a non-standard FolderBrowserDialog.RootFolder Property, or the functional root-folder equivalent

Ron Sipherd 241 Reputation points

So far as I can tell, the
FolderBrowserDialog.RootFolder Property
can only be one of the
Environment.SpecialFolder Enum values.

I would like to open a folder browser dialog rooted at a data directory of my choice.
Am looking at how to do this, and not finding a good (simple) solution.
Is there one?

An object-oriented programming language developed by Microsoft that is implemented on the .NET Framework. Previously known as Visual Basic .NET.
2,661 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jiachen Li-MSFT 28,946 Reputation points Microsoft Vendor

    Hi @Ron Sipherd ,
    You can try to use FolderBrowserDialog.SelectedPath Property to set the initial directory displayed by the folder browser dialog.
    FolderBrowserDialog1.SelectedPath = "C:\Users\Administrator\Desktop" before showdialog.
    Best Regards.
    Jiachen Li


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. RLWA32 43,046 Reputation points

    You can drop down to the Windows API functions using p/invoke to achieve your objective. Following is a quick example in .Net Framework 4.8 using a Windows Forms project (Error handling omitted). Sorry about posting an image, the site wouldn't accept posted code.


    And the execution -




    0 comments No comments

  2. Ron Sipherd 241 Reputation points

    Thanks to both of you! I'll take a closer look and respond.

    0 comments No comments

  3. Ron Sipherd 241 Reputation points

    SelectedPath is not the same as a root folder, but it's good enough for this task.
    I'll dive into PInvoke when I run into a problem that requires it.

    Did lots of DLL calls back when I was young and foolish