-1
コンソールアプリケーション(テストアプリケーション)の入力をC#プログラム(モニタアプリケーション)に入力するにはどうすればよいですか?私は正常にテストアプリケーションでコード化されているコンソールから、私のモニターアプリケーションに文字列の値を持っている。今私は、ユーザーがテストアプリケーションでコンソールから文字列を入力することを許可したいと私は私の監視されているアプリケーションからテストアプリケーションでそのユーザー入力文字列をキャプチャしたい。コンソールプログラムからC#プログラムへのユーザー入力データの取得方法は?
テストアプリとモニタアプリのコードです。
テストアプリ
using System;
namespace TestApp
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Test2");
Console.Write("Enter a string ");
string txtOne = Console.ReadLine();
Console.WriteLine(txtOne);
//Console.ReadLine();
}
}
}
モニターアプリコード
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace GetStandardOutput
{
class Program
{
static void Main()
{
//
// Setup the process with the ProcessStartInfo class.
//
ProcessStartInfo start = new ProcessStartInfo();
start.FileName = @"C:\Users\erandaka\Documents\Visual Studio 2015\Projects\TestApp\TestApp\bin\Debug\TestApp.exe"; // Specify exe name.
start.UseShellExecute = false;
start.RedirectStandardOutput = true;
//
// Start the process.
//
using (Process process = Process.Start(start))
{
//
// Read in all the text from the process with the StreamReader.
//
using (StreamReader reader = process.StandardOutput)
{
string result = reader.ReadToEnd();
Console.Write(result);
Console.ReadLine();
}
}
}
}
}
が意見をいただきありがとうございます、私は、ユーザーが私のC#のプログラムにコンソールウィンドウを介してデータを入力された取得する必要があります。 –