0

ここに C# のコードがあります。これの機能は、フォルダー内のファイルのリストを生成することです。

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

これは cmd onC:\testを実行するだけで、引数は実行されません。何か足りないものはありますか?

4

1 に答える 1

3

/c「残りをコマンドとして実行する」という引数が必要です。

ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe",
    "/c dir /B /S *.* > D:\\tempf.txt");

CMD のヘルプから:

/C      Carries out the command specified by string and then terminates
于 2013-05-20T06:10:50.420 に答える