在"\r\n"
中尝试了VS2003
和environment.newline以获取换行符。我们使用"\r\n"
或environment.newline在stringbuilder中编写文本并将其保存在IO文件中。在IE11中打开时,NewLine break在文件中不起作用,而如果在记事本中打开则它可以正常工作。如果在较早版本的IE8
中打开它,也可以使用。
代码的一部分是:
StringBuilder cdataDescription = new StringBuilder();
cdataDescription.Append("* This is an install activity which passed through SYR.").Append(newline);
cdataDescription.Append("\r\n");
//For CSI
cdataDescription.Append(" Please dispatch to the IBG * ");
cdataDescription.Append("\r\n");
cdataDescription.AppendLine();
cdataDescription.Append("test");
cdataDescription.Append("\r\n");
cdataDescription.Append("General Information");
cdataDescription.Append("\r\n");
cdataDescription.Append("---------------------------------------");
cdataDescription.Append("\r\n");
string result = string.empty;
result = cdataDescription.ToString();
return result;
答案 0 :(得分:-2)
理想情况下,只要编写文本文件,新行char就是“\ n”。 您可能需要检查用于写入文件的字符集。 Windows记事本仅支持ASCII,您可以在Norepad ++中打开文件,因为它支持不同的字符集。
还要注意UNIX和Windows风格。