tags:

views:

250

answers:

2
+4  A: 

My Computer is a virtual folder. It has a predefined GUID. Here is how you get My Computer

 OpenFileDialog d = new OpenFileDialog();
 d.InitialDirectory = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}";
 d.ShowDialog();

If you want to know about special folders

http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx

but be aware of

The MyComputer constant always yields the empty string ("") because no path is defined for the My Computer folder.

Svetlozar Angelov
Wow... way to change something like 'My Computer' into something much much clearer :)
David Brunelle
+1  A: 

A good way to handle this is using the "special folders" in the .NET Environment library.

For instance, the "My Documents" (personal) would use:

Environment.GetFolderPath(Environment.SpecialFolder.Personal)
chills42
I tried this but this doensn't seem to work out :dlgOpen.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer)
David Brunelle
Svetlozar Angelov is correct though... it looks like "My Computer" is actually undefined...
chills42
Personal is My Documents...
Svetlozar Angelov
Guess my computer doesn't work because I get "" when I substitute Personal for MyComputer. I'll use Desktop instead.Tks
David Brunelle
"::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" is "the directory" you need.....
Svetlozar Angelov