|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to set OpenFileDialog to "My Computer"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. ----- 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 > 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 > 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 > > 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 >> > > 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 > >> > > > Steve Marshall wrote:
> Thanks Robin, but at the moment I'm a VS2003 user, and I think Then you'll be after GetFolderPath(Environment.SpecialFolder.MyComputer).> My.Computer... is a VS2005 and/or Framework 2 feature. HTH Andrew "Andrew Morton" <a**@in-press.co.uk.invalid> schrieb: .... which won't be very useless because the path assigned to 'MyComputer' is >> 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). "". 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/> 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/> |
|||||||||||||||||||||||