locked
Open Folder programmatically in vb.net

    Question

  • Hi

    In VB.net I have a Form , textbox and Commant Button,

    In textbox I have entered path e.g "C:\Temp\Temp1"

    When i click the command button the location "C:\Temp\Temp1" should get opened in windows explorer.

     

    Thanks in Advance

    Sidheshwar.

    Tuesday, March 06, 2007 5:45 AM

Answers

  • I have found the solution

    here it is ... in vb.net

    Process.Start("explorer.exe", Folder_Path)

    Tuesday, March 06, 2007 8:31 AM

All replies

  • I have found the solution

    here it is ... in vb.net

    Process.Start("explorer.exe", Folder_Path)

    Tuesday, March 06, 2007 8:31 AM
  • Thanks for the solution.It is very useful for me.Thanks a lot.
    Friday, June 01, 2007 11:42 AM
  • Me too.  Thanks!
    Wednesday, June 20, 2007 7:55 AM
  • Yes. It was helpful to me. Thank you.

    Thursday, August 23, 2007 6:10 AM
  •  

    Thanks a lot, it was helpful to me.

    Monday, February 11, 2008 7:50 PM
  • Thank you for the explanation...  I have just one more question. How would I open the folder as you described and then highlight / select (Not Open) a specific file in that folder. It would be like when you use the Search

    link in the start button then when the list comes up with all the items in the browser you can right click and select "Open Containing Folder" the folder opens and the file is highlighted and focus is on that file??

     

    I am using the following

     

    Code Snippet

    Dim info As IO.FileInfo = My.Computer.FileSystem.GetFileInfo(path)

    path = info.DirectoryName

     

    Process.Start("explorer.exe", path)

     

     

     

     

    Thank you in advanced 

    Ken

     

    Answering my own Question

    sPath  = full path of the file you want highlighted in the containing folder.

     

    Code Snippet

    Call Shell("explorer /select," & sPath, AppWinStyle.NormalFocus)

     

     

    Hope this helps some one so they don't have to search msdn for weeks like I did sifting thru everything except what I placed in the search bar.... YIKES
    • Proposed as answer by rodoss2019 Tuesday, November 22, 2011 7:31 AM
    Wednesday, March 26, 2008 6:46 PM
  • Very useful for sure ! This was what I searched (not very seriously) for months !
    Wednesday, April 16, 2008 2:18 PM
  • Thanks lot..... Very helpfull to me

    Tuesday, April 29, 2008 5:19 AM
  • This will open the folder with details view
    Process.Start("explorer.exe", "/e," & TextBox1.Text)

    • Proposed as answer by scp03 Thursday, July 16, 2009 6:43 PM
    Thursday, July 16, 2009 6:42 PM
  • Ok process.start("explorer.exe", folder_path) works great for opening the windows explorer to that folder, but . . .

    Is there a way to remember that particular window and later on programmatically close it?

     

    Thanks,


    the mighty man
    Tuesday, April 13, 2010 3:10 AM
  • This thread  might help you
    Wednesday, April 14, 2010 5:59 PM
  • Thanks! it solved my problem.
    Friday, January 28, 2011 9:16 AM
  • Answering my own Question

    sPath  = full path of the file you want highlighted in the containing folder.

     

     

     

    Code Snippet
     

    Call Shell("explorer /select," & sPath, AppWinStyle.NormalFocus)

     

     

     

     

    Hope this helps some one so they don't have to search msdn for weeks like I did sifting thru everything except what I placed in the search bar.... YIKES

    hey thanks for that piece of code but it seems to fail if the filename has an apostrophe in it for e.g filename = i can't get with that.mp3....it opens up the wrong folder

    can u suggest a way to make it work? i tried using string.replace(" ' "," // ' ") but doesnt seem to work..any ideas guys? anyone? would appreciate any help . THANK YOU!     PS I am using VB.net

    Friday, April 08, 2011 5:57 AM
  • Hello all, the above code works perfectly with the apostrophe also...i was using it wrong...I am using a sqlite database in VB.net, so i had replaced the ' with '' ....so in short...i just had to remove one ' ...thank you all!!!
    Saturday, April 09, 2011 1:45 AM
  •  

    Dim path As String

    path = "%temp%\folder1"

    Dim objShell = CreateObject("Wscript.Shell")

    objShell.run(path)

     

     

    Sunday, April 17, 2011 6:31 PM
  • Dude you are awesome , I was looking for the same. Thanks A lot.
    Thursday, July 14, 2011 10:52 AM
  • Your tip on using Call Shell worked for me. A big thanks for posting this. I had been using Process.start(folderPath). This is much better because it selects the targeted file.

     

    Friday, November 11, 2011 4:30 AM