<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=C-Sharp_-_FolderDialog_Issues</id>
	<title>C-Sharp - FolderDialog Issues - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://performiq.com/kb/index.php?action=history&amp;feed=atom&amp;title=C-Sharp_-_FolderDialog_Issues"/>
	<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=C-Sharp_-_FolderDialog_Issues&amp;action=history"/>
	<updated>2026-05-18T18:31:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://performiq.com/kb/index.php?title=C-Sharp_-_FolderDialog_Issues&amp;diff=5199&amp;oldid=prev</id>
		<title>PeterHarding: Created page with &quot; The Browser Folder Dialog in ASP.NET 1.1 allows you to select a folder.  There is a property, RootFolder, that allows you to select what folder is the root in the dialog.  Th...&quot;</title>
		<link rel="alternate" type="text/html" href="https://performiq.com/kb/index.php?title=C-Sharp_-_FolderDialog_Issues&amp;diff=5199&amp;oldid=prev"/>
		<updated>2021-10-16T19:39:17Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot; The Browser Folder Dialog in ASP.NET 1.1 allows you to select a folder.  There is a property, RootFolder, that allows you to select what folder is the root in the dialog.  Th...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&lt;br /&gt;
The Browser Folder Dialog in ASP.NET 1.1 allows you to select a folder.  There is a property, RootFolder, that allows you to select what folder is the root in the dialog.  The RootFolder property can be set to any of the values in the System.Environment.SpecialFolder enum in the .NET Framework. However, there may be settings that are not in that enumeration that you may want to use.  For example, you may want to set the root to be My Network Places.&lt;br /&gt;
&lt;br /&gt;
It turns out that the Browse Folder Dialog is a cover for a Windows API call.  The Windows API call takes a parameter that is a constant that indicates what the root should be. For some reason the allowed constants in Windows were not fully implemented in the System.Environment.SpecialFolder enum (for no good reason that I can figure out).&lt;br /&gt;
&lt;br /&gt;
You can&amp;#039;t just set the RootFolder property to the values in the constants provided by Windows.  Instead you will have to pull a trick using Reflection to modify the internally stored number in a private variable inside the dialog.&lt;br /&gt;
&lt;br /&gt;
Include the following class in your project:&lt;br /&gt;
&lt;br /&gt;
[c#]&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.Reflection;&lt;br /&gt;
&lt;br /&gt;
public sealed class FolderBrowserDialogEx&lt;br /&gt;
{&lt;br /&gt;
    [Flags()]&lt;br /&gt;
    public enum CsIdl&lt;br /&gt;
    {&lt;br /&gt;
        Desktop =                   0x0000, // Desktop&lt;br /&gt;
        Internet =                  0x0001, // Internet Explorer (icon on desktop)&lt;br /&gt;
        Programs =                  0x0002, // Start Menu\Programs&lt;br /&gt;
        Controls =                  0x0003, // My Computer\Control Panel&lt;br /&gt;
        Printers =                  0x0004, // My Computer\Printers&lt;br /&gt;
        Personal =                  0x0005, // My Documents&lt;br /&gt;
        Favorites =                 0x0006, // user name\Favorites&lt;br /&gt;
        Startup =                   0x0007, // Start Menu\Programs\Startup&lt;br /&gt;
        Recent =                    0x0008, // user name\Recent&lt;br /&gt;
        SendTo =                    0x0009, // user name\SendTo&lt;br /&gt;
        BitBucket =                 0x000a, // desktop\Recycle Bin&lt;br /&gt;
        StartMenu =                 0x000b, // user name\Start Menu&lt;br /&gt;
        MyDocuments =               0x000c, // logical &amp;quot;My Documents&amp;quot; desktop icon&lt;br /&gt;
        MyMusic =                   0x000d, // &amp;quot;My Music&amp;quot; folder&lt;br /&gt;
        MyVideo =                   0x000e, // &amp;quot;My Videos&amp;quot; folder&lt;br /&gt;
        DesktopDirectory =          0x0010, // user name\Desktop&lt;br /&gt;
        Drives =                    0x0011, // My Computer&lt;br /&gt;
        Network =                   0x0012, // Network Neighborhood (My Network Places)&lt;br /&gt;
        Nethood =                   0x0013, // user name\nethood&lt;br /&gt;
        Fonts =                     0x0014, // windows\fonts&lt;br /&gt;
        Templates =                 0x0015,&lt;br /&gt;
        CommonStartMenu =           0x0016, // All Users\Start Menu&lt;br /&gt;
        CommonPrograms =            0x0017, // All Users\Start Menu\Programs&lt;br /&gt;
        CommonStartup =             0x0018, // All Users\Startup&lt;br /&gt;
        CommonDesktopDirectory =    0x0019, // All Users\Desktop&lt;br /&gt;
        AppData =                   0x001a, // user name\Application Data&lt;br /&gt;
        PrintHood =                 0x001b, // user name\PrintHood&lt;br /&gt;
        LocalAppData =              0x001c, // user name\Local Settings\Applicaton Data (non roaming)&lt;br /&gt;
        AltStartup =                0x001d, // non localized startup&lt;br /&gt;
        CommonAltStartup =          0x001e, // non localized common startup&lt;br /&gt;
        CommonFavorites =           0x001f,&lt;br /&gt;
        InternetCache =             0x0020,&lt;br /&gt;
        Cookies =                   0x0021,&lt;br /&gt;
        History =                   0x0022,&lt;br /&gt;
        CommonAppdata =             0x0023, // All Users\Application Data&lt;br /&gt;
        Windows =                   0x0024, // GetWindowsDirectory()&lt;br /&gt;
        System =                    0x0025, // GetSystemDirectory()&lt;br /&gt;
        ProgramFiles =              0x0026, // C:\Program Files&lt;br /&gt;
        MyPictures =                0x0027, // C:\Program Files\My Pictures&lt;br /&gt;
        Profile =                   0x0028, // USERPROFILE&lt;br /&gt;
        SystemX86 =                 0x0029, // x86 system directory on RISC&lt;br /&gt;
        ProgramFilesX86 =           0x002a, // x86 C:\Program Files on RISC&lt;br /&gt;
        ProgramFilesCommon =        0x002b, // C:\Program Files\Common&lt;br /&gt;
        ProgramFilesCommonx86 =     0x002c, // x86 Program Files\Common on RISC&lt;br /&gt;
        CommonTemplates =           0x002d, // All Users\Templates&lt;br /&gt;
        CommonDocuments =           0x002e, // All Users\Documents&lt;br /&gt;
        CommonAdminTools =          0x002f, // All Users\Start Menu\Programs\Administrative Tools&lt;br /&gt;
        AdminTools =                0x0030, // user name\Start Menu\Programs\Administrative Tools&lt;br /&gt;
        Connections =               0x0031, // Network and Dial-up Connections&lt;br /&gt;
        CommonMusic =               0x0035, // All Users\My Music&lt;br /&gt;
        CommonPictures =            0x0036, // All Users\My Pictures&lt;br /&gt;
        CommonVideo =               0x0037, // All Users\My Video&lt;br /&gt;
        Resources =                 0x0038, // Resource Directory&lt;br /&gt;
        ResourcesLocalized =        0x0039, // Localized Resource Directory&lt;br /&gt;
        CommonOemLinks =            0x003a, // Links to All Users OEM specific apps&lt;br /&gt;
        CdBurnArea =                0x003b, // USERPROFILE\Local Settings\Application Data\Microsoft\CD Burning&lt;br /&gt;
        ComputersNearMe =           0x003d, // Computers Near Me (determined from Workgroup membership)&lt;br /&gt;
        FlagCreate =                0x8000, // combine with CSIDL_ value to force folder creation in SHGetFolderPath()&lt;br /&gt;
        FlagDontVerify =            0x4000, // combine with CSIDL_ value to return an unverified folder path&lt;br /&gt;
        FlagNoAlias =               0x1000, // combine with CSIDL_ value to insure non-alias versions of the pidl&lt;br /&gt;
        FlagPerUserInit =           0x0800, // combine with CSIDL_ value to indicate per-user init (eg. upgrade)&lt;br /&gt;
        FlagMask =                  0xFF00, // mask for all possible flag values&lt;br /&gt;
    }&lt;br /&gt;
        &lt;br /&gt;
    private FolderBrowserDialogEx()&lt;br /&gt;
    {&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    public static void SetRootFolder(System.Windows.Forms.FolderBrowserDialog fbd, CsIdl csidl)&lt;br /&gt;
    {&lt;br /&gt;
        Type t = fbd.GetType();&lt;br /&gt;
        FieldInfo fi = t.GetField(&amp;quot;rootFolder&amp;quot;, BindingFlags.Instance | BindingFlags.NonPublic);&lt;br /&gt;
        fi.SetValue(fbd, (System.Environment.SpecialFolder) csidl);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To set the FolderRoot property, call it like this:&lt;br /&gt;
&lt;br /&gt;
[c#]&lt;br /&gt;
&lt;br /&gt;
  FolderBrowserDialogEx.SetRootFolder(fbd, FolderBrowserDialogEx.CsIdl.Network);&lt;br /&gt;
&lt;br /&gt;
Where fbd is the name of the FolderBrowserDialog on your form, and the second argument is what you want to use as the root of the dialog.&lt;/div&gt;</summary>
		<author><name>PeterHarding</name></author>
	</entry>
</feed>