Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MyComputer as initial directory

Tags:

dialog

wpf

Is there a way for a open file dialog to use the "My Computer" instead of a specific path. In this example, the W: drive is the intial directory.

Dim dlgOpen As New Microsoft.Win32.OpenFileDialog

dlgOpen.Filter = "Bases de données Access(*.mdb)|*.mdb"
dlgOpen.InitialDirectory = "W:"

I figure there must be a value or function that return the My Computer path, but what is it?

Thank you

like image 349
David Brunelle Avatar asked Nov 03 '09 13:11

David Brunelle


1 Answers

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.

like image 126
Svetlozar Angelov Avatar answered Oct 02 '22 12:10

Svetlozar Angelov