Home All Groups Group Topic Archive Search About

How to set OpenFileDialog to "My Computer"

Author
2 Nov 2006 12:28 AM
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

Author
2 Nov 2006 1:52 AM
Tim Patrick
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

Show quoteHide quote
> 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
>
Author
2 Nov 2006 1:58 AM
Tim Patrick
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/issues/03/03/CuttingEdge/

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

Show quoteHide quote
> 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
>
Author
2 Nov 2006 8:42 AM
Steve Marshall
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:
Show quoteHide quote
> 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/issues/03/03/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
> >
Author
2 Nov 2006 7:22 PM
RobinS
You could try My.Computer.FileSystem.SpecialDirectories.Desktop. At least
from there, they can easily choose "My Computer".
Robin

Show quoteHide quote
"Steve Marshall" <ste***@westnet.net.au> wrote in message
news:1162456949.131564.132830@h54g2000cwb.googlegroups.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/issues/03/03/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
>> >
>
Author
3 Nov 2006 3:23 PM
Steve Marshall
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:
Show quoteHide quote
> You could try My.Computer.FileSystem.SpecialDirectories.Desktop. At least
> from there, they can easily choose "My Computer".
> Robin
>
> "Steve Marshall" <ste***@westnet.net.au> wrote in message
> news:1162456949.131564.132830@h54g2000cwb.googlegroups.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/issues/03/03/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
> >> >
> >
Author
3 Nov 2006 4:12 PM
Andrew Morton
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
Author
3 Nov 2006 7:48 PM
Herfried K. Wagner [MVP]
"Andrew Morton" <a**@in-press.co.uk.invalid> schrieb:
>> 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/>
Author
6 Nov 2006 10:04 AM
Steve Marshall
Works beautifully -  many thanks Herfried, and all other respondents
too.


Herfried K. Wagner [MVP] wrote:
Show quoteHide quote
> "Andrew Morton" <a**@in-press.co.uk.invalid> schrieb:
> >> 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/>