tags:

views:

803

answers:

5

currently i have used guid to open mycomputer and my documents

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

but it opens ie then opens my computer and my documents

+2  A: 

Try explorer.exe:

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

Have you tried:

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

?

User
thank u worked for me
JKS
+18  A: 

Using those hard coded Guid values doesn't look like the best way of achieving this.

You could use the Environment.GetFolderPath function to get the path of any of the system special folders. It accepts an Environment.SpecialFolder enum.

This way it'd be more robust, because you wouldn't have any "magic" hardcoded values.

Here's how you'd use it:

//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);
DoctaJonez
This also looks far more readable than the accepted answer
Patrick McDonald
for mynetwork places how do i use
JKS
how do i open recyclebin
JKS
+2  A: 

Better still would be to skip "explorer" entirely and just "start" the GUIDs directly:

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

hard-core!This will provide lots of fun for the junior developer who'll have to debug through this kind of code 5 years from now :)
SWeko
A: 

This does not work for my Vista:

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

as Environment.SpecialFolder.MyComputer returns "" and Process.Start("explorer", "") opens My Documents.

The GUID seems to do it, though:

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