c#从richtextbox中写到文件里不换行
privatevoidsaveToolStripMenuItem_Click(objectsender,EventArgse){DialogResulta;SaveFil...
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult a; SaveFileDialog save = new SaveFileDialog(); a = save.ShowDialog(); if (a == DialogResult.OK) { FileStream fs = new FileStream(save.FileName, FileMode.Create, FileAccess.Write); byte[] b; //b = new byte[c.Length]; richTextBox1.Text.Replace("\n", "\r\n"); richTextBox1.Text.Replace("\r", "\r\n"); b = Encoding.Default.GetBytes(richTextBox1.Text); fs.Seek(0, SeekOrigin.Begin); fs.Write(b, 0, b.Length); fs.Close(); } DialogResult Dr; Dr = MessageBox.Show(save.FileName + "保存成功", "保存成功", MessageBoxButtons.OK); }richitextbox里有换行,但是写完了打开文件就成一行了然后如果打开a文件保存到b文件,b比a少了几个换行符的大小
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询