How to set OpenFileDialog to "My Computer"

  • Thread starter Thread starter Steve Marshall
  • Start date Start date
S

Steve Marshall

Hi All,

Is it possible to set the InitialDirectory property of an
OpenFileDialog so it will open at the "My Computer" level? I want it
to open showing all the available drives. If so, what do I put in the
property? I've tried the obvious - "My Computer", but of course that
doesn't do it.

Thanks
 
The "My Computer" folder isn't a real directory, so you can't access it using
normal directory methods. In Visual Basic 2005, you can access all of the
drives through the My.Computer.FileSystem.Drives collection.
 
Thanks for that. I'm not sure I want or need to go to quite that
length, but I'll try to take it all in.
 
You could try My.Computer.FileSystem.SpecialDirectories.Desktop. At least
from there, they can easily choose "My Computer".
Robin
 
Thanks Robin, but at the moment I'm a VS2003 user, and I think
My.Computer... is a VS2005 and/or Framework 2 feature.
 
Steve said:
Thanks Robin, but at the moment I'm a VS2003 user, and I think
My.Computer... is a VS2005 and/or Framework 2 feature.

Then you'll be after GetFolderPath(Environment.SpecialFolder.MyComputer).

HTH

Andrew
 
Andrew Morton said:
Then you'll be after GetFolderPath(Environment.SpecialFolder.MyComputer).

.... which won't be very useless because the path assigned to 'MyComputer' is
"".

What you can try instead (untested!):

\\\
Const STR_MYCOMPUTER_CLSID As String =
"{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
fbd.InitialDirectory = "::" & STR_MYCOMPUTER_CLSID
///
 
Back
Top