这会将txtChange的文本转储到文本文件中. txtChange是一个Rich文本框,其中包含换行符(新行).
This dumps the text of txtChange to a text file. txtChange is a Rich text box and has line breaks (new lines) in it.
当用户单击转储"按钮时,所有文本都会被转储,但不会出现在新行上.
When the user clicks the Dump button all the text is Dumped but not on new lines.
例如txtChange看起来像
E.g. txtChange looks like
1 2 3 4转储文本看起来像1234
如何设置文本转储的格式,以使文本位于新行上?
推荐答案您应使用 Lines 属性改为:
You should use the Lines property instead:
File.WriteAllLines(@"E:\TestFile.txt", txtChange.Lines);您真的不需要使用流,因为File类包含这些静态便捷方法-简而言之.
You don't really need to use a stream since the File class contains these static convenience methods - short and to the point.
以上内容将所有现有内容替换为文本框txtChange中包含的文本行.如果要附加内容,请改用适当命名的File.AppendAllLines().
Above will replace any existing content with the text lines contained in your text box txtChange. If you want to append content use the appropriately named File.AppendAllLines() instead.
更多推荐
使用换行符将文本转储到文件
发布评论