FolderBrowserDialog.RootFolder displays desktop folders when you set it to non-desktop values (818459)



The information in this article applies to:

  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual C# .NET (2003)
  • the operating system: Microsoft Windows 98
  • the operating system: Microsoft Windows NT 4.0

SYMPTOMS

You create a FolderBrowserDialog control on a Windows form, and you set the RootFolder property to one of the following values:
  • CommonApplicationData
  • CommonProgramFiles
  • Cookies
  • History
  • InternetCache
  • LocalApplicationData
  • LocalApplicationData
  • MyPictures
  • ProgramFiles
  • System
When you run the application on a computer that is running the Microsoft Windows 98 operating system or the Microsoft Windows NT 4.0 operating system, a Browse For Folder dialog box is displayed with the folders on the desktop, instead of displaying the folders in the selected RootFolder.

CAUSE

This is a limitation of the BrowseForFolder method on the Windows 98 operating system and the Windows NT 4.0 operating system.

Note The BrowseForFolder method creates the BrowseForFolder dialog box. This dialog box allows the user to select a folder.

STATUS

This behavior is by design.

MORE INFORMATION

The Microsoft Visual Studio .NET or Visual Studio 2005 IDE will only run on computers that are running the Windows 2000 operating system or a later version. Therefore, it is a good idea to build the sample application on a computer that is running the Windows 2000 operating system or a later version. Install Microsoft .NET Framework 1.1 on a computer that is running the Windows 98 operating system, and then copy the executable file that you built on a computer that runs the Windows 2000 operating system or a later version.

Steps to Reproduce the Behavior

  1. In Microsoft Visual Studio .NET (2003) or in Microsoft Visual Studio 2005, create a new Windows application by using Visual Basic 2005, Microsoft Visual Basic .NET, or Microsoft Visual C#.

    By default, Form1 is created.
  2. From the toolbox, drag a FolderBrowserDialog control to Form1.
  3. Right-click FolderBrowserDialog1, and then click Properties.
  4. In the Properties window, set the RootFolder property to ProgramFiles.
  5. From the toolbox, drag a Button control to Form1.
  6. Add the following code to the Click event of Button1.

    Visual Basic .NET or Visual Basic 2005 Code
    ' Displays a dialog box that allows the user to select a folder.
     FolderBrowserDialog1.ShowDialog()
    Visual C# .NET Code
    //Displays a dialog box that allows the user to select a folder.
    folderBrowserDialog1.ShowDialog();
  7. From the toolbox, drag a Button control to Form1.
  8. Add the following code to the Click event of Button2.

    Visual Basic .NET or Visual Basic 2005 Code
    ' Displays the path of program files folder in your local computer.
    MsgBox(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles))
    Visual C# .NET Code
    //Displays the path of program files folder in your local computer.
    MessageBox.Show(System.Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
  9. On the Build menu, click Build Solution.
  10. Locate WindowsApplication1.exe under the Bin subfolder of the WindowsApplication1 project.
  11. Copy WindowsApplication1.exe to the computer that is running the Windows 98 operating system.
  12. Right-click WindowsApplication1.exe, and then click Open.
  13. Click Button1.

    The folders on the desktop are displayed in Browse For Folder.
  14. Click Button2.

    You receive a message box with the path of the Program Files folder.

REFERENCES

For more information, visit the following MSDN Web site:

Modification Type:MinorLast Reviewed:10/3/2006
Keywords:kbvs2005applies kbvs2005swept kbprb kbProperties kbdisplay kbWindowsForms kbDirectory kbdir kbCtrl kbControl KB818459 kbAudDeveloper