我有这个方法
private void _executeCommand(string commandStr, int timeout)
{
try
{
System.Diagnostics.ProcessStartInfo procStartInfo =
new System.Diagnostics.ProcessStartInfo("cmd", "/c " + commandStr);
procStartInfo.RedirectStandardOutput = true;
procStartInfo.UseShellExecute = false;
// Do not create the black window.
procStartInfo.CreateNoWindow = true;
// Now we create a process, assign its ProcessStartInfo and start it
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo = procStartInfo;
proc.Start();
Thread.Sleep(timeout);
}
catch (ExecutionEngineException e)
{
throw e;
}}
不知何故,如果我传递一个名为myCmd
,的字符串_executeCommand(myCmd, timeout)
,它什么也不做。但是,如果我传递 , 的确切字符串值myCmd
,_executeCommand("copy //data//file \"C://Program Files/myApp\"", timeout)
它就能够执行。谁能看到问题是什么?