什么是写一个StringBuilder到一个文本文件中的内容在.NET 1.1中最简单的方法是什么?最简单、文本文件、方法、内容

2023-09-03 15:51:25 作者:撞枪口

我必须使用的,而不是因为被套牢.NET 1.1本项目字符串列表的StringBuilder。它真的抽筋我的风格,并让我觉得我穿着褴褛旧豹皮的哑弹,并通过泥土拖着一个波诡云谲的俱乐部。

I have to use StringBuilder instead of a List of string because of being stuck with .NET 1.1 for this project. It's really cramping my style, and making me feel like I'm wearing raggedy old leopard skin duds and dragging a lumpy club through the dirt.

不管怎样,我想写一系列调试封邮件我已经写入文件,在我的闲暇来研究,因为有太多的屏幕上看到(在MessageBox没有滚动条)。一些简单的方法来写一个文件似乎并没有在.NET 1.1中提供。我还没有获得Environment.Newline干净地分离我追加线(AppendLine不StringBuilder的这个古老的版本,无论是)。

Anyway, I want to write a series of debug msgs I've written to a file to study at my leisure, as there is too much to see on the screen (the MessageBox doesn't have scrollbars). Some of the easy ways to write a file don't seem to be available in .NET 1.1. I also don't have access to Environment.Newline to cleanly separate the lines I append (AppendLine is not available in this archaic version of StringBuilder, either).

够牢骚,我猜...什么是.NET 1.1(C#)最简单的方法写出来的StringBuilder的内容到一个文件?有没有C驱动器在手持设备上,所以我想我将不得不把它写入\ hereIAm.txt左右。

Enough whining, I guess...What is the easiest way in .NET 1.1 (C#) to write out the contents of the StringBuilder to a file? There is no "C" drive on the handheld device, so I reckon I will have to write it to "\hereIAm.txt" or so.

推荐答案

您仍然有机会获得的StreamWriter

System.IO.StreamWriter file = new System.IO.StreamWriter("\hereIam.txt");
file.WriteLine(lines);

http://msdn.microsoft.com/en-us/library/aa287548(v=vs.71).aspx