How to open the folders "My Documents" and "My Computer" with C #?

I used two GUIDs to open the My Computer and My Documents folders.

Process.Start("iexplore.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
Process.Start("iexplore.exe", "::{450d8fba-ad25-11d0-98a8-0800361b1103}");

But he opens Internet Explorer, and then opens the My Computer and My Documents folders.

+3
source share
9 answers

It would be best to skip explorercompletely and simply β€œrun” the GUID directly:

Process.Start("::{20d04fe0-3aea-1069-a2d8-08002b30309d}");...

+5
source

Using these hard-coded Guid values ​​doesn't seem like the best way to achieve this.

Environment.GetFolderPath, . Environment.SpecialFolder enum.

, , "" .

:

//get the folder paths
string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
//open explorer and point it at the paths
System.Diagnostics.Process.Start("explorer", myComputerPath);
System.Diagnostics.Process.Start("explorer", myDocumentsPath);

Windows 7

, My Computer Windows 7 , Libraries. , Windows Windows 7.

connect, , , !

https://connect.microsoft.com/VisualStudio/feedback/details/757291/environment-getfolderpath-not-working-correctly-in-windows-7#details

( )

+36

:

Process.Start("explorer.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
Process.Start("explorer.exe", "::{450d8fba-ad25-11d0-98a8-0800361b1103}");

?

+9

explorer.exe:

Process.Start("explorer.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
Process.Start("explorer.exe", "::{450d8fba-ad25-11d0-98a8-0800361b1103}");
+6

Vista:

string myComputerPath = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer);
System.Diagnostics.Process.Start("explorer", myComputerPath);

Environment.SpecialFolder.MyComputer ", Process.Start(" explorer "," ") .

, GUID :

Process.Start("explorer.exe", "::{20d04fe0-3aea-1069-a2d8-08002b30309d}");
+2
System.Diagnostics.Process.Start("...");

, , . . . , .

+1

System.Diagnostics.Process.Start("...");

, , . . . , .

Windows 7 , , "" .

0

MyDocuments , Explorer :

Process.Start("::{450d8fba-ad25-11d0-98a8-0800361b1103}");

Windows Server 2008 R2.

0

Samdoss

System.Diagnostics.Process.Start(directoryPath);

. .

-1

Source: https://habr.com/ru/post/1711735/


All Articles