Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# FolderBrowserDialog RootFolder "Mycomputer" not functioning on Windows 10

Tags:

c#

Using Visual Studio 2015, I am writing a Windows Form Application in C#. I use the following code:

FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.RootFolder = Environment.SpecialFolder.MyComputer;

On my development machine (Windows 8.1) this works as expected, the FolderBrowserDialog appears with "This Computer" as the root directory.

However when I transfer the program to a windows 10 machine (I have tried both pro and home versions of Windows 10) the FolderBrowserDialog opens with "Desktop" as to root directory.

Is there a different SpecialFolder that I should be using specific to Windows 10?

like image 486
agthatch Avatar asked Oct 30 '22 05:10

agthatch


1 Answers

I know MyComputer was renamed to ThisPC in Windows 8 and 10 so interesting that would work in 8 but not 10. What path do you get if you run this:

string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);

Does it resolve to 'This PC'.

Also you could try this, which gets the path by the MyComputer Guid:

FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.SelectedPath = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
like image 188
David Oesterreich Avatar answered Nov 12 '22 20:11

David Oesterreich