0
我有我讀的文本文件到使用按鈕一個StreamReader點擊 我已格式的文本文件,我希望它內顯示的方式一個RichTextBox該文本文件,使用段落,但是當我添加文本到RichTextBox格式消失。 有沒有辦法從文本文件讀入文本時,我可以格式化文本單獨段落?格式文本
這是我的代碼:
using (StreamReader reader = new StreamReader(@"F:\test.txt"))
{
bool content = false;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("[7]"))
{
content = true;
continue;
}
if (content == true)
{
txtContent.AppendText(line.Replace("[7]", "").Replace("[/7]", ""));
}
if (line.Contains("[/7]"))
{
content = false;
break;
}
}
}
的[7]和[/ 7]參考我已經添加到我的文本文件,從而讀取器僅讀取其間這些標籤和僅顯示選擇的文本標籤其間
感謝您的幫助
是它的Windows Phone或者Windows窗體或WPF? – 2015-04-01 10:25:04
@AnupSharma它是一個視窗形式應用 – FlipperFlapper 2015-04-01 10:27:12