Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Stream  problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
csharpula csharp - 07 Feb 2008 16:49 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.