VB:未处理的异常

时间:2014-05-07 17:31:35

标签: vb.net exception unhandled

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

  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'类型的未处理异常

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

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

1 个答案:

答案 0 :(得分:0)

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

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

相关问题