이 코드를 사용하여 두 개의 숫자를 asp.net을 통해 C 프로그램 파일의 .exe에 입력으로 전달한 다음 콘솔에서 출력을 읽으려고합니다. 콘솔에서 출력물을 읽는 데 문제가 있습니다.asp.net을 통해 콘솔에서 출력 읽기
내 asp.net 코드입니다.
문자열 반환 값;
Process p = new Process();
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
p.StartInfo.FileName = ("C:\\Users\\...\\noname01.exe");
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.Start();
Thread.Sleep(500);
SendKeys.SendWait("1");
Thread.Sleep(500);
SendKeys.SendWait("~");
Thread.Sleep(500);
SendKeys.SendWait("2");
Thread.Sleep(500);
SendKeys.SendWait("~");
Thread.Sleep(500);
StreamReader sr = p.StandardOutput;
returnvalue = sr.ReadToEnd();
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\Users\\Hussain\\Documents\\Visual Studio 2012\\WebSites\\WebSite4\\Data\\StudentOutput.txt");
file.WriteLine(returnvalue);
입력을 전달하는 코드입니다.
#include<stdio.h>
int main()
{
int a, b, c;
printf("Enter two numbers to add\n");
scanf("%d%d",&a,&b);
c = a + b;
printf("Sum of entered numbers = %d\n",c);
return 0;
}
모든 종류의 도움이 필요합니다.
그리고 ... 무엇이 문제입니까? –
콘솔에서 출력을 읽을 수 없습니다. –