已嘗試"\r\n"
和VS2003
中的environment.newline以獲取換行符。我們使用"\r\n"
或environment.newline在stringbuilder中編寫文本並將其保存在IO文件中。在IE11中打開文件時NewLine中斷不起作用,而在記事本中打開時文件起作用。如果它在IE8
的舊版本中打開,這也適用。「 r n」或VS2003中的environment.newline不適用於IE11或Chrome
代碼的部分是:
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;
那麼你在瀏覽器中打開一個純文本文件還是HTML?這裏沒有足夠的上下文... –
使用
作爲新行,如果將其保存爲.html文件 – shreesha
爲什麼不使用AppendLine而不是Append?期待記事本和任何版本的IE以相同的方式顯示文件是不合理的。一個用於編輯文本文件,另一個用於查看html文件。 – juharr