Hello,
I am using the following code in COnsole C# application:
TextWriter tw = new StreamWriter(LogFileName);
while ((inputLine = _streamReader.ReadLine()) != null)
{
lineNumber++;
if (lineNumber > ReadLines)
{
tw.WriteLine(inputLine);
}
}
The problem is that the output is written in file and in console and I
want it to be written in file only. How can I avoid it be written to the
console?
Thank u!
Nicholas Paldino [.NET/C# MVP] - 07 Feb 2008 17:31 GMT
You will want to call the static SetOut method on the Console class:
http://technet.microsoft.com/en-us/library/system.console.setout.aspx
That should prevent the output from going to the console, and send it to
your TextWriter.

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hello,
> I am using the following code in COnsole C# application:
[quoted text clipped - 15 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
Jon Skeet [C# MVP] - 07 Feb 2008 18:47 GMT
> I am using the following code in COnsole C# application:
> TextWriter tw = new StreamWriter(LogFileName);
[quoted text clipped - 10 lines]
> want it to be written in file only. How can I avoid it be written to the
> console?
On its own, that's very unlikely to write to the console.
Could you post a short but complete program which demonstrates the
problem?
See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Kalpesh - 07 Feb 2008 18:48 GMT
Is this the only code in your console application?
I suspect some other code before this must be writing to the console
Kalpesh