[RESOLVED] [2008] Open a folder from VB with file selected
This pertains to .NET 2.0, so really 2005 or 2008 is relevant to this question.
NOTE: When I use the term "explorer" or "windows explorer" i am referring to the windows shell, not Internet Explorer, which I will always call "Internet Explorer" or "IE"
I am looking for a way to launch a given folder in windows explorer from VB, however I need to also instruct it to select a certain file in the folder.
A good example of this is when you download a file via Internet Explorer. When it is done, you have the option to launch the file directly, or open the directory it was downloaded to. If you select to open the directory, it shells that directory in an explorer window, but also selects the file, which helps the user not need to look through the entire directory for it.
So I need a way to do this.
I know to simply open a folder, its process.start("folderpath"), but I don't know if there are additional params I can use to select the file, or if I will need to go the route of shelling to explorer.exe with some params to select the file.
If anyone knows, please fill me in. I am looking around the web for a solution now to.
Re: [2008] Open a folder from VB with file selected
I figured it out, using explorer with command line switches.
Code:
Process.Start("explorer.exe", "/select,C:\somedir\somefile.txt")
Re: [RESOLVED] [2008] Open a folder from VB with file selected
Can it be done with multiple files as well? This is something I've wanted to be able to do ever since I wrote my first line of code!
Re: [RESOLVED] [2008] Open a folder from VB with file selected
Quote:
Opens a window view with the specified folder, file or
program selected.
If it said "specified folders, files, or programs selected" then I would say maybe, but it sounds to me like its only made for selecting single files. The closest you could get to multiple files, is selecting a directory.
http://support.microsoft.com/kb/307856
There may be some other programmatic way to do it, but not as simple as shelling out explorer with a few arguments.