0
저는 Streams의 초보자입니다. Process의 StandardOutput을 리디렉션하고 다른 곳에서 소비 될 수 있도록 StandardOutput Stream을 반환하는 함수를 작성하려고합니다. 메서드에서 Process.StandardOutput Stream을 반환하면 해당 Stream은 어떻게 저장됩니까? 그것이 소비 될 때까지 그냥 어딘가에 살고 있습니까? 최대 크기가 있습니까? , CompareStreams()에 따라서Process.StandardOutput 스트림은 어떻게 저장됩니까?
public Stream GetStdOut(string file)
{
_process = new Process(file);
_process.StartInfo.UseShellExecute = false;
_process.StartInfo.RedirectStandardOutput = true;
_process.Start();
return _process.StandardOutput;
}
public bool CompareStreams()
{
Stream s1 = GetStdOut("somefile.exe");
Stream s2 = GetStdOut("anotherfile.exe");
using (StreamReader sr1 = new StreamReader(s1))
using (StreamReader sr2 = new StreamReader(s2))
{
string line_a, line_b;
while ((line_a = sr1.ReadLine()) != null &&
(line_b = sr2.ReadLine()) != null)
{
if (line_a != line_b)
return false;
}
return true;
}
}
내가 스트림에 대한 스트림 (S1) I가 발생하고있어 동안 데이터와 관련된 데이터의 양에 대해 걱정해야 할 : 여기
내가 지금까지 가지고 그 일부 예제 코드입니다 s2? 아니면 별 문제가 아닌가?
즉, 버퍼링 된 출력 스트림입니다. –