Reputation: 821
I have a code here in C#, the function of this is to generate a list of files in a folder:
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe", "dir /B /S *.* > D:\\tempf.txt");
processStartInfo.WorkingDirectory = @"C:\test";
Process.Start(processStartInfo);
This will just run cmd on C:\test
and the arguments are not executed. Is there something missing?
Upvotes: 1
Views: 158
Reputation: 1503529
You need the /c
argument to say "execute the rest as a command":
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd.exe",
"/c dir /B /S *.* > D:\\tempf.txt");
From the help for CMD:
/C Carries out the command specified by string and then terminates
Upvotes: 4