【发布时间】:2015-12-24 17:34:21
【问题描述】:
我注意到我使用下面的代码创建的文件中没有换行符。在我也存储文本的数据库中,这些都存在。
string story = "Critical error occurred after "
+ elapsed.ToString("hh:mm:ss")
+ "\n\n" + exception.Message;
File.WriteAllText(path, story);
所以在short googling 之后,我了解到我应该使用 Environment-NewLine 而不是文字 \n 来引用新行。所以我添加了如下所示。
string story = "Critical error occurred after "
+ elapsed.ToString("hh:mm:ss")
+ "\n\n" + exception.Message;
.Replace("\n", Environment.NewLine);
File.WriteAllText(path, story);
仍然,输出文件中没有换行符。我错过了什么?
【问题讨论】:
标签: c# file line-breaks