我遇到了普通记事本问题。在记事本中单行显示的文本
如果我在写字板中打开文件,它会正确显示富文本框中的文本(使用文本框中的换行符)。但是在记事本中它只是一条巨大的线条,我如何才能在写入文件时识别富文本框中的换行符?
我所做的是打开一个记事本文件,其中包含一段文本并进入richtextBox1。
从第一个文本框中复制文本,然后在richTextBox2中写入第一个richtextbox中的文本和复制文本中删除元音(copytext)以及写入第二个记事本文件(_Parsed.text)。
string Chosen_File = "C:\\_Testfile.txt";
string Second_File = "C:\\_Parsed.txt";
string wholeText = "";
private void mnuOpen_Click(object sender, EventArgs e) {
//Add data from text file to rich text box
richTextBox1.LoadFile(Chosen_File, RichTextBoxStreamType.PlainText);
//Read lines of text in text file
string textLine = "";
StreamReader txtReader;
txtReader = new StreamReader(Chosen_File);
do {
textLine = textLine + txtReader.ReadLine() + " ";
}
//Read line until there is no more characters
while (txtReader.Peek() != -1);
richTextBox1.Text = textLine;
txtReader.Close();
}
}
private void Write(string file, string text) {
//Check to see if _Parsed File exists
//Write to _Parsed text file
using(StreamWriter objWriter = new StreamWriter(file)) {
objWriter.Write(text);
objWriter.Close();
}
}
private void newSummaryMethod(string copyText) {
//Write into richTextBox2 all relevant text
copyText = richTextBox1.Text;
wholeText = richTextBox1.Text + copyText
Write(Second_File, wholeText);
}
private void btn1_Click(object sender, EventArgs e) {
newSummaryMethod(copyText);
}
请编辑您的问题,其中显示在大的代码块问题存在...... –
你没有使用你的nl变量 –
我在编辑我的问题后想我知道是什么问题。 – user21255