如何从Visual Studio C#.net创建带有自动换行属性的文本文件(.txt)?

Asa*_*sad 1 .net c# string word-wrap

如何从Visual Studio C#.net创建带有自动换行属性的文本文件(.txt)?

实际上我正在维护一个日志文件,其中一些值以表格形式存储,但表格内容超出了行限制,我希望表格值显示在一行中.

有办法吗?

非常感谢您的回复!

问候

She*_*Pro 6

您在记事本中将Word Wrap与字符串混淆.您在txt文件中从C#添加的字符串未被包装..如果在WordWrap打开时,可能会在记事本中看到它.

存储在txt文件中的字符串将永远不会自行进行任何自动换行.(对于新行,您没有任何自动换行符\n \n).


Word Wrap是任何文本编辑器的功能,它与实际字符串(文本)无关.以下是维基百科关于其含义的摘录.

In text display, line wrap is the feature of continuing on a new line 
when a line is full, such that each line fits in the viewable window, allowing 
text to be read from top to bottom without any horizontal scrolling.

Word wrap is the additional feature of most text editors, word processors, 
and web browsers, of breaking lines between and not within words, except 
when a single wordis longer than a line.


如果您不想在编辑器中使用文本禁用它(如Notpad).你不能在字符串(文本)本身做任何事情(其他然后\n在需要时添加一定数量的单词后添加).