Results 1 to 4 of 4

Thread: [RESOLVED] [2008] Open a folder from VB with file selected

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Resolved [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.

  2. #2

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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")

  3. #3
    Frenzied Member obi1kenobi's Avatar
    Join Date
    Aug 2007
    Posts
    1,091

    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!
    Please rate helpful ppl's posts. It's the best 'thank you' you can give

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: [RESOLVED] [2008] Open a folder from VB with file selected

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width