I can call the console app from the asp.net web forms but if I have input one by one like below once I got the first argument from user input then they have another input please enter another number then user need to input another argument in console app. I have 2 arguments but both will take one by one. If single argument at first time then I can pass as below but with 2 I could not. How this possible If some one help then that would be good. I want to pass both argument.
Process p1 = new Process();
p1.StartInfo.FileName = "ConsoleEx.exe"; // actual file name
p1.StartInfo.Arguments = "1 ";
p1.StartInfo.UseShellExecute = false;
p1.StartInfo.RedirectStandardOutput = true;
p1.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p1.Start();
p1.WaitForExit();
if (p1.HasExited)
{
string output = p1.StandardOutput.ReadToEnd();
lblConsoleOutput.Text = output;
p1.Dispose();
}
static void Main(string[] args)
{
int num1, num2;
int add, sub, mul;
float div;
Console.Write("Enter 1st number\t");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write("\nEnter 2nd number\t");
num2 = Convert.ToInt32(Console.ReadLine());}
Here is the image
Redirect the standard input and stream the values by code.
You can find an example here; http://msdn.microsoft.com/en-gb/library/system.diagnostics.processstartinfo.redirectstandardinput%28v=vs.110%29.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.