Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to open a new "My Computer" explorer window in C#?

Status
Not open for further replies.

asasadadafaf

Technical User
Mar 18, 2008
5
0
0
HK
Hi,

My question is very simple, as subject, How to open a new "My Computer" explorer window in C#? Just like you double click "My Computer" icon on the desktop. I tried to search around google but have no clue how to do that?

Many thanks for your help

 
using System.Diagnostics;

public static void OpenWindow(string path)
{
System.Diagnostics.Process.Start(path);

//If the above doesn't work try
System.Diagnostics.Process.Start("explorer.exe", path);
}

 
thanks, but how should i setup the path if i want to point it to "My computer"? i tried to put "My computer" as path but it doesn't work,many thanks
 
Thanks JurkMonkey, I tried this but it opens "My documents" instead, many thanks for your help!
 
I found that if you run explorer with no path it opens my documents but if you use empty string it opens My Computer.

That was on a Windows 2000 machine.

You may want to look into the Environment.SpecialFolder list and see if there's one for the computer path.

 
Many thanks, i tried to do some research about Environment.SpecialFolder but it seems that this function will return a PAth actually, but you know "My computer" is not actually a Folder at all, and if i use this function for "My Computer" it will returns "blank" and leads going to "My documents" instead, any other hints for achieve this? many thanks again!
 
i tried to put " " as path, now it works , many thanks!
 
Cool trick! =) works on cmd line too (i'm running XP)!

c:\>explorer<space><space><enter>

[wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top