File.WriteAllText不preserve换行 [英] File.WriteAllText Doesn't Preserve Newline

查看:189
本文介绍了File.WriteAllText不preserve换行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这code的输出

string fileDateTime = "StepsGA-" + DateTime.Now.ToString("dd-MM-yyyy-HH-mm-ss") + ".txt";
string fname = System.IO.Path.Combine(System.Environment.CurrentDirectory, fileDateTime);
File.WriteAllText(fname, txtSteps.Text);

不preserve换行符理所应当的。文本框中的所有内容打印在一个水平长线!我在哪里出了错?谢谢!

doesn't preserve newline as it should be. All the contents of the textbox are printed in a horizontal long line ! Where have I gone wrong? Thanks !

推荐答案

得到了答案!相反的\ñ我需要使用 Environment.NewLine

Got the answer ! Instead of \n I needed to use Environment.NewLine.

这篇关于File.WriteAllText不preserve换行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆