Process.Start(“ echo”,“%cd%”)引发W32Exception文件未找到 [英] Process.Start("echo", "%cd%") throws W32Exception File Not Found

查看:88
本文介绍了Process.Start(“ echo”,“%cd%”)引发W32Exception文件未找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试执行 Process.Start( echo,%cd%)时,它会引发 System.ComponentModel.Win32Exception:系统找不到指定的文件
当我在 cmd 中手动执行此操作时,它会按应有的方式工作。我从来不知道有什么区别……

When I try to do Process.Start("echo", "%cd%") it raises a System.ComponentModel.Win32Exception: The system cannot find the file specified. When I do this manually in cmd it just works like it should. I never knew that there's a difference...

此外,当我执行 File.Exists(logfile.txt)(绝对路径)绝对应该存在的文件,它返回false。这是上面 echo 的原因:调试...

Also, when I do File.Exists(logfile.txt) (w/o path) of a file that should definitely be there, it returns false. This is btw the reason for the echo above: debugging...

此错误不会在我的计算机上发生开发机器,仅在我正在测试的另一台机器上。

This error doesn't occur on my developement machine, only on another one where I am testing on.

Path变量看起来很正常。两者都是WinXP。两者都在运行.NET 3.5

The Path variable looks normal. Both are WinXP. Both are running .NET 3.5

推荐答案

尝试 Process.Start( cmd.exe, / c echo%CD%)

只要echo不是可执行文件而是内部命令。

as far as echo is not an executable but a command inside.

这篇关于Process.Start(“ echo”,“%cd%”)引发W32Exception文件未找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆