Click here to Skip to main content
15,844,477 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The debug window is slowing me down severely, but all I want to see from it is the last few lines. I would like to not run the debug window and send the last 5 lines of the debug window to an external text file. Can someone please show me how to do this?

1 solution

            StringBuilder sb = new StringBuilder();

            StringWriter sw = new StringWriter(sb);

            TextWriterTraceListener myWriter = new TextWriterTraceListener(sw);


            string output = string.Join("\n",

The last line is likely to be empty so you may want to exclude empty rows from the set of rows in the stringbuilder.
Share this answer
computerpublic 18-May-15 17:13pm    
I don't see where you named and created any external file?? How do you do this??
Andy Lanng 19-May-15 4:08am    

I gave you gold. Writing to an external file from a string is SO common you can google it:
computerpublic 23-May-15 10:21am    
I still cannot figure out how to complete what you wrote. I don't understand why you would write something incomplete.
Andy Lanng 26-May-15 4:23am    
Because it's not my place to write your code for you. That's not what this site is about.
You really can't work out how to write text to a file? Maybe you should post a new question. Please include in the question exactly where you are stuck.
Sergey Alexandrovich Kryukov 29-May-15 10:42am    
Ah, now I see: I guess you were the one who misled our inquirer to this trash:

Please don't get me wrong: I don't blame you, but perhaps you have to ask the inquirer what he is trying to do and why this debug window at all, why using Debug and Trace. And then I tried to answer next question, at least until this person lost patience and started to play rude:

Your advice to post a new question did not work :-(


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900