-5

My program crashes every time I click a button that points to a loop, here is the snippet of code that it points to:

  Public Function ExecuteCommand(ByVal filePath As String, ByVal arguments As String)     As String
        Dim p As Process
        p = New Process()
        p.StartInfo.FileName = filePath
        p.StartInfo.Arguments = arguments
        p.StartInfo.CreateNoWindow = True
        p.StartInfo.UseShellExecute = False
        p.StartInfo.RedirectStandardOutput = True
        p.Start()  // points to this line
        Return p.StandardOutput.ReadToEnd()
    End Function

the error reads "An unhandled exception of type 'System.ComponenetModel.Win32Exception' occured in System.dll

Additional information: The system cannot find the file specified

any help would be greatly appreciated. Thanks.

1 Answers1

0

Obviously enough the executable file provided as the FileName does not exist on disk.

You might want to check for its existence before trying to execute it.

Crono
  • 10,211
  • 6
  • 43
  • 75