-5

每次单击指向循环的按钮时,我的程序都会崩溃,这是它指向的代码片段:

  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

错误显示“System.dll 中发生了“System.ComponenetModel.Win32Exception”类型的未处理异常

附加信息:系统找不到指定的文件

任何帮助将不胜感激。谢谢。

4

1 回答 1

0

显然,提供的可执行文件FileName在磁盘上不存在。

您可能想在尝试执行它之前检查它的存在。

于 2014-05-07T17:35:15.337 回答