By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,586 Members | 623 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,586 IT Pros & Developers. It's quick & easy.

How to set OpenFileDialog to "My Computer"

P: n/a
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

Nov 2 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
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.

-----
Tim Patrick
Start-to-Finish Visual Basic 2005
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

Nov 2 '06 #2

P: n/a
Oops, I misread your post. Sorry for the useless information.

You have to use the ID of the folder to access it. This article gives the
details.

http://msdn.microsoft.com/msdnmag/is...3/CuttingEdge/

-----
Tim Patrick
Start-to-Finish Visual Basic 2005
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

Nov 2 '06 #3

P: n/a
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.
Tim Patrick wrote:
Oops, I misread your post. Sorry for the useless information.

You have to use the ID of the folder to access it. This article gives the
details.

http://msdn.microsoft.com/msdnmag/is...3/CuttingEdge/

-----
Tim Patrick
Start-to-Finish Visual Basic 2005
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
Nov 2 '06 #4

P: n/a
You could try My.Computer.FileSystem.SpecialDirectories.Desktop. At least
from there, they can easily choose "My Computer".
Robin

"Steve Marshall" <st****@westnet.net.auwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
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.
Tim Patrick wrote:
>Oops, I misread your post. Sorry for the useless information.

You have to use the ID of the folder to access it. This article gives the
details.

http://msdn.microsoft.com/msdnmag/is...3/CuttingEdge/

-----
Tim Patrick
Start-to-Finish Visual Basic 2005
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

Nov 2 '06 #5

P: n/a
Thanks Robin, but at the moment I'm a VS2003 user, and I think
My.Computer... is a VS2005 and/or Framework 2 feature.
RobinS wrote:
You could try My.Computer.FileSystem.SpecialDirectories.Desktop. At least
from there, they can easily choose "My Computer".
Robin

"Steve Marshall" <st****@westnet.net.auwrote in message
news:11**********************@h54g2000cwb.googlegr oups.com...
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.
Tim Patrick wrote:
Oops, I misread your post. Sorry for the useless information.

You have to use the ID of the folder to access it. This article gives the
details.

http://msdn.microsoft.com/msdnmag/is...3/CuttingEdge/

-----
Tim Patrick
Start-to-Finish Visual Basic 2005

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
Nov 3 '06 #6

P: n/a
Steve Marshall wrote:
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
Nov 3 '06 #7

P: n/a
"Andrew Morton" <ak*@in-press.co.uk.invalidschrieb:
>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 ).
.... 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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 3 '06 #8

P: n/a
Works beautifully - many thanks Herfried, and all other respondents
too.
Herfried K. Wagner [MVP] wrote:
"Andrew Morton" <ak*@in-press.co.uk.invalidschrieb:
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 ).

... 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
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 6 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.