调试窗口到外部文件 [英] Debug Window to External File
本文介绍了调试窗口到外部文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
调试窗口让我严重受挫,但我想从中看到的只是最后几行。我想不运行调试窗口并将调试窗口的最后5行发送到外部文本文件。有人可以告诉我该怎么做吗?
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?
推荐答案
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
TextWriterTraceListener myWriter = new TextWriterTraceListener(sw);
Debug.Listeners.Add(myWriter);
//...
string output = string.Join("\n",
sb.ToString().Split('\n').Reverse().Take(5).Reverse());
最后一行可能是空的,因此您可能希望从stringbuilder中的行集中排除空行。
The last line is likely to be empty so you may want to exclude empty rows from the set of rows in the stringbuilder.
这篇关于调试窗口到外部文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文