[英]Can I call console app exe from asp.net with 2 argument?
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. 我可以从asp.net Web表单调用控制台应用程序,但是如果我从用户输入中得到第一个自变量,则按如下所示逐个输入,则他们有另一个输入,请输入另一个数字,然后用户需要在控制台中输入另一个自变量应用程式。 I have 2 arguments but both will take one by one. 我有2个论点,但两者都会一一对应。 If single argument at first time then I can pass as below but with 2 I could not. 如果是第一次使用单个参数,那么我可以按以下方式进行传递,但使用2则不能。 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 http://msdn.microsoft.com/zh-CN/library/system.diagnostics.processstartinfo.redirectstandardinput%28v=vs.110%29.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.