C # start process arguments passed to data

trying to pass data from file as argument to cmd string in C # and run into problems

ProcessStartInfo startInfo1 = new ProcessStartInfo();
startInfo1.FileName = @"myexe.exe";
startInfo1.UseShellExecute = false;
startInfo1.RedirectStandardOutput = true;
startInfo1.WindowStyle = ProcessWindowStyle.Hidden;
startInfo1.WorkingDirectory = @"C:\myfolder\";
startInfo1.Arguments = "-cmd1 x -cmd2 y  < c:\\yesfile.txt";

the problem is with <c: \ yesfile.txt ...

when I debug and grab .Arguments and execute from cmd line works fine. working from code i get

Invalid command line parameters: <

searching around, I cannot find a way to do this (pass data) from code. Exe, which I call, does not accept "y" as the cmd argument, so I need to pass it from the file so that it starts automatically this way.

Update : how to get std input and pass y (based on response) - make sure you RedirectStandardInput = true;also

       StreamWriter inputWriter = myProcess.StandardInput;
                    inputWriter.Write("y");
                    inputWriter.Flush();
                    inputWriter.Close();
+3
source share
2 answers

, <, > .. , Windows - Process.Start.

Process.StandardInput , "y" startInfo1.RedirectStandardInput = true;

+3

, ' > '

startInfo1.Arguments = "-cmd1 x -cmd2 y  > c:\\yesfile.txt"; 
-1

All Articles