Process.Start(“echo”, “

后端 未结 3 1429
误落风尘
误落风尘 2021-01-19 00:41

When I try to do Process.Start(\"echo\", \"%cd%\") it raises a System.ComponentModel.Win32Exception: The system cannot find the file specified. Whe

3条回答
  •  耶瑟儿~
    2021-01-19 01:35

    You can use System.Environment.CurrentDirectory if you want to pass the working directory of your application to cmd. AFAIK %CD% is internal to cmd, that's why Process.Start won't expand it. For ordinary environment variables you can use Environment.ExpandEnvironmentVariables.

提交回复
热议问题