在某些计算机上,当我打电话Process.Start()
开始帮助我的可执行文件,我得到以下异常抛出:手柄Win32Exception通过的Process.Start()
System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
的问题:当我Win32Exception
,我想告诉是否这是我描述的“找不到文件”异常或其他内容。如何可靠地做到这一点?我应该比较这个0x80004005
,还是应该解析错误信息?
一些解释:由于某种原因,可执行文件可能会被删除(这就是为什么没有找到文件)。这是一个预期的情况。如果因为其他原因抛出异常,我想报告它。
'0x80004005'是[E_FAIL](https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137(v = vs.85).aspx)。这是非常通用的,不会有帮助。 [NativeErrorCode](https://msdn.microsoft.com/en-us/library/system.componentmodel.win32exception.nativeerrorcode(v = vs.110).aspx)可能会带来更好的运气。 – GSerg