Reputation: 1903
I'm trying to get console input from inside a WPF application. In the Project properties I've set it as a console application and the output works. However, now I want to be able to read input from the console since I haven't started working on the views yet. I found this snippet on here, but I don't believe it's what I was looking for:
Process compiler = new Process();
compiler.StartInfo.FileName = "C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\csc.exe";
compiler.StartInfo.Arguments = "/r:System.dll /out:sample.exe stdstr.cs";
compiler.StartInfo.UseShellExecute = false;
compiler.StartInfo.RedirectStandardOutput = true;
compiler.Start();
Console.WriteLine(compiler.StandardOutput.ReadToEnd());
compiler.WaitForExit();
Upvotes: 1
Views: 1240
Reputation: 6075
Why not simply use Console.ReadLine()
?
string userInput = Console.ReadLine();
Upvotes: 1