1

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?

1 Answer 1

4

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 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.