Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Process.Start()参数无效_C#_Cmd - Fatal编程技术网

C# Process.Start()参数无效

C# Process.Start()参数无效,c#,cmd,C#,Cmd,我在C#中有一段代码,其功能是生成文件夹中的文件列表: ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "dir /B /S *.* > D:\\tempf.txt"); processStartInfo.WorkingDirectory = @"C:\test"; Process.Start(processStartInfo); 这将只在C:\test上运行cmd,并且不会执行参数。缺少什么吗?您需

我在C#中有一段代码,其功能是生成文件夹中的文件列表:

ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "dir /B /S *.* > D:\\tempf.txt");
processStartInfo.WorkingDirectory = @"C:\test";
Process.Start(processStartInfo);

这将只在
C:\test
上运行cmd,并且不会执行参数。缺少什么吗?

您需要
/c
参数来表示“将其余部分作为命令执行”:

从CMD的帮助中:

/C      Carries out the command specified by string and then terminates

您需要
/c
参数来表示“将其余部分作为命令执行”:

从CMD的帮助中:

/C      Carries out the command specified by string and then terminates