none
System.Diagnostics.Process.Start("explorer.exe", serverpath) - fails after 2 attempts

    Question

  • I am trying to use Process.Start to open a folder using explorer on the click of a window.

    It works fine on the first two clicks of the button i.e. the folder is opened and on closing the windows and click on the button a third time gives the error message

    "the path "C:\test" is not found or is not a directory"

    If anyone has any info on how to solve it, please share..

    Dim myProcess As Process = New Process()
    ServerPath="C:\test"

    ServerPath =

    """" + ServerPath + """"
    myProcess.StartInfo.UseShellExecute = False 
    myProcess.Start("explorer.exe", ServerPath)

    I have tried both setting UseShellExecute to False and True

    thanks
    Saturday, November 28, 2009 1:34 AM

Answers

  • No repro

     Dim si As New ProcessStartInfo("Explorer")
            si.UseShellExecute = False
            Dim ServerPath = "C:\test"
            si.Arguments = ServerPath
            Process.Start(si)
    

    Arjun Paudel
    • Marked as answer by vamsi Monday, November 07, 2011 9:19 PM
    Saturday, November 28, 2009 5:32 AM

All replies

  • No repro

     Dim si As New ProcessStartInfo("Explorer")
            si.UseShellExecute = False
            Dim ServerPath = "C:\test"
            si.Arguments = ServerPath
            Process.Start(si)
    

    Arjun Paudel
    • Marked as answer by vamsi Monday, November 07, 2011 9:19 PM
    Saturday, November 28, 2009 5:32 AM
  • Thanks Arjun

    this works well if the folder is on my local computer.
    But the same problem repeats if the folder is a network folder.

    i.e.

    1. First time on the button click, folder is opened in explorer window. Close the window
    2.Click on the button second time, folder is again opened in expoerer window. Close the window
    3.CLick on the button a third time, get an error message

    THE PATH "\abcd\xyz\" does not exist or is not a directory

    4. Navigate from that windows form to a different form and come back again to the first form  and click on the button, the folder opens (after 2 attempts, the same error message is repeated. The cycle repeats)

    I have even tried this

    myProcess.WaiteForExit()
    myProcess.Close()
    but the same error message repeats on the third attempt











    Saturday, November 28, 2009 7:19 AM
  • If I remember this correctly, the issue was with my code.

    the variable ServerPath was being appended with some values incorrectly.

    Monday, November 07, 2011 9:19 PM