GarethWham
asked on
Open windows explorer from VB.net
Help!
I need to open windows explorer from vb.net project. Also when I open windows explorer I wish for it to display a particular folder.
Now, I am unsure whether this can be done, but I need a solution fairly urgently hence the points!
Many thanks in advance,
Regards,
Gareth
I need to open windows explorer from vb.net project. Also when I open windows explorer I wish for it to display a particular folder.
Now, I am unsure whether this can be done, but I need a solution fairly urgently hence the points!
Many thanks in advance,
Regards,
Gareth
try this
Shell("c:\windows\explorer " & URL)
or this
System.Diagnostics.Process .Start("Ex plorer.exe ", "c:\data")
EXPLORER.EXE [/n][/e][,/root,<object>][ [,/select] ,<sub object>]
Switches
/n: Opens a new window in single-paned (My Computer) view for each item
selected, even if the new window duplicates a window that is
already open.
/e: Uses Windows Explorer view. Windows Explorer view is most similar
to File Manager in Windows version 3.x. Note that the default view
is Open view.
/root,<object>: Specifies the root level of the specified view. The
default is to use the normal namespace root (the
desktop). Whatever is specified is the root for the
display.
/select,<sub object>: Specifies the folder to receive the initial
focus. If "/select" is used, the parent folder
is opened and the specified object is selected.
Shell("c:\windows\explorer
or this
System.Diagnostics.Process
EXPLORER.EXE [/n][/e][,/root,<object>][
Switches
/n: Opens a new window in single-paned (My Computer) view for each item
selected, even if the new window duplicates a window that is
already open.
/e: Uses Windows Explorer view. Windows Explorer view is most similar
to File Manager in Windows version 3.x. Note that the default view
is Open view.
/root,<object>: Specifies the root level of the specified view. The
default is to use the normal namespace root (the
desktop). Whatever is specified is the root for the
display.
/select,<sub object>: Specifies the folder to receive the initial
focus. If "/select" is used, the parent folder
is opened and the specified object is selected.
ASKER
iboutchkine,
Thanks for your post. I used shell to open explorer using the following code:
Shell("C:\windows\explorer ", vbMaximizedFocus)
I want to point explorer to a particular folder do I use /select? how do you write <sub object>, if you use select.#
Could you possibly give me the code for, say opening My Pictures as it is usually general path via (My Documents/My Pictures).
Many thanks for your help so far,
Gareth
Thanks for your post. I used shell to open explorer using the following code:
Shell("C:\windows\explorer
I want to point explorer to a particular folder do I use /select? how do you write <sub object>, if you use select.#
Could you possibly give me the code for, say opening My Pictures as it is usually general path via (My Documents/My Pictures).
Many thanks for your help so far,
Gareth
Try to use Explorer switches
EXPLORER.EXE [/n][/e][,/root,<object>][ [,/select] ,<sub object>]
Switches
/n: Opens a new window in single-paned (My Computer) view for each item
selected, even if the new window duplicates a window that is
already open.
/e: Uses Windows Explorer view. Windows Explorer view is most similar
to File Manager in Windows version 3.x. Note that the default view
is Open view.
/root,<object>: Specifies the root level of the specified view. The
default is to use the normal namespace root (the
desktop). Whatever is specified is the root for the
display.
/select,<sub object>: Specifies the folder to receive the initial
focus. If "/select" is used, the parent folder
is opened and the specified object is selected.
Shell("C:\windows\explorer c:\test", vbMaximizedFocus)
EXPLORER.EXE [/n][/e][,/root,<object>][
Switches
/n: Opens a new window in single-paned (My Computer) view for each item
selected, even if the new window duplicates a window that is
already open.
/e: Uses Windows Explorer view. Windows Explorer view is most similar
to File Manager in Windows version 3.x. Note that the default view
is Open view.
/root,<object>: Specifies the root level of the specified view. The
default is to use the normal namespace root (the
desktop). Whatever is specified is the root for the
display.
/select,<sub object>: Specifies the folder to receive the initial
focus. If "/select" is used, the parent folder
is opened and the specified object is selected.
Shell("C:\windows\explorer
You can work out the directories of special folders like my pictures, my documents and favourites by using
SpecialFolder = new DirectoryInfo(System.Envir onment.Get FolderPath (Environme nt.Special Folder.Fav orites)
SpecialFolder = new DirectoryInfo(System.Envir
ASKER
I know the paths of the folder but how do you actually write the code for it I have tried:
Shell("C:\windows\explorer ""C:\My Documents\Document1.doc")
But cant get it to work.
If a use select switch how do I write in 'sub object'?
/select,<sub object>: Specifies the folder to receive the initial
focus. If "/select" is used, the parent folder
is opened and the specified object is selected.
Cant get the code to work using /select,("C:\My Documents\Document1.doc")
Thanks
Gareth
Shell("C:\windows\explorer
But cant get it to work.
If a use select switch how do I write in 'sub object'?
/select,<sub object>: Specifies the folder to receive the initial
focus. If "/select" is used, the parent folder
is opened and the specified object is selected.
Cant get the code to work using /select,("C:\My Documents\Document1.doc")
Thanks
Gareth
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Gareth, you just need to remove the "" in your above code, or use the & sign like below
Shell("C:\windows\explorer " & "C:\My Documents\Document1.doc")
Adding the vbMaximizedFocus can also be useful in order to force the window to come up in front, give that a go
Shell("C:\windows\explorer
Adding the vbMaximizedFocus can also be useful in order to force the window to come up in front, give that a go
ASKER
Hello,
Thanks all for your comments.
I have tried using shell but have been unsuccessful. I have manged to open explorer and point to the foldr I want using 'iboutchkine's suggestion of:
System.Diagnostics.Process .Start("Ex plorer.exe ", "c:\data")
However, when the explorer window opens I want its focus to be maximized. I have tried ',vbMaximizedFocus' but vb.net says that this line of code has too many arguments?
Any suggestions,
Cheers,
Gareth
Thanks all for your comments.
I have tried using shell but have been unsuccessful. I have manged to open explorer and point to the foldr I want using 'iboutchkine's suggestion of:
System.Diagnostics.Process
However, when the explorer window opens I want its focus to be maximized. I have tried ',vbMaximizedFocus' but vb.net says that this line of code has too many arguments?
Any suggestions,
Cheers,
Gareth
Shell("Explorer.exe " & """" & "C:\Archivos de Programa" & """", AppWinStyle.MaximizedFocus )
Imports InetCtlsObjects
Microsoft Internet Transfer Control 6.0 (SP4) <----- THE DLL