wha*_*ame 3 c# diagnostics process du
这令人难以置信.使用以下代码:
Process du = new Process();
string cmdPath = System.IO.Path.Combine(Environment.SystemDirectory, "du.exe");
Debug.WriteLine(cmdPath);
ProcessStartInfo info = new ProcessStartInfo(cmdPath);
info.CreateNoWindow = true;
info.Arguments = arguments;
info.UseShellExecute = false;
info.RedirectStandardOutput = true;
du.StartInfo = info;
du.EnableRaisingEvents = true;
du.OutputDataReceived += responseParser;
du.Start();
du.BeginOutputReadLine();
du.WaitForExit();
Run Code Online (Sandbox Code Playgroud)
我跑了,我得到:
未处理的异常:System.ComponentModel.Win32Exception:系统找不到指定的文件
虽然cmdPath的输出值是C:\Windows\system32\du.exe!
当然,如果我只是输入cmdPath命令提示符的内容,它运行du.exe并给我使用信息.
此外,如果我用"du.exe"替换命令路径,并将du.exe放在工作目录中,一切正常.但我想引用系统位置中的那个.
那么发生了什么?据我所知,我有一个合法的文件说明符,但为什么不Process.Start()执行呢?这个基本代码也执行其他几个程序并获得它们的输出.其他都工作正常,虽然du.exe与它们不同,因为它位于system32目录中.这与它有关吗?
谢谢
| 归档时间: |
|
| 查看次数: |
10352 次 |
| 最近记录: |