M
mabra
Hi All !
Problem:Reading/duplicating "Console.In" fails for unknown reason.
I wrote a little console helper tool, named TEE, which just duplicates
the StdIn to the StdOut AND an additional stream. Looks working
basically and the part that does this is like the following:
private static void CopyStream(TextWriter outStream, bool dup)
{
char temp;
while(Console.In.Peek() != -1)
{
temp = Convert.ToChar(Console.In.Read());
outStream.Write(temp);
if(dup) Console.Out.Write(temp);
}
}
I use it like this:
dir /s /b /a:-d d:\Develop | Tee d:\Develop.log
But unexpectedly, the resuling textfile does not contain all text send
by the dir command. And, for each time, the resulting textfile has other
content. This lokks like, the loop, shown above, terminates for unknown
reason at a random point.
I do not know, what is wrong with my code.
Any idea why this happens is really very welcome!
Thanks so far and
best regards,
Manfred
Problem:Reading/duplicating "Console.In" fails for unknown reason.
I wrote a little console helper tool, named TEE, which just duplicates
the StdIn to the StdOut AND an additional stream. Looks working
basically and the part that does this is like the following:
private static void CopyStream(TextWriter outStream, bool dup)
{
char temp;
while(Console.In.Peek() != -1)
{
temp = Convert.ToChar(Console.In.Read());
outStream.Write(temp);
if(dup) Console.Out.Write(temp);
}
}
I use it like this:
dir /s /b /a:-d d:\Develop | Tee d:\Develop.log
But unexpectedly, the resuling textfile does not contain all text send
by the dir command. And, for each time, the resulting textfile has other
content. This lokks like, the loop, shown above, terminates for unknown
reason at a random point.
I do not know, what is wrong with my code.
Any idea why this happens is really very welcome!
Thanks so far and
best regards,
Manfred