知道字符串和文本路径,实现文本读取到字符串,实现字符串写入到文本:
![](https://i-blog.csdnimg.cn/blog_migrate/63cda44e4609ef3f58a1cb26a79b7adf.png)
//文本读取到字符串
using (StreamReader sr = new StreamReader(m_rootpath + "\\" + name))
{
richTextBox1.Text = sr.ReadToEnd();
}
//字符串写入到文本
using (StreamWriter sw = new StreamWriter(m_rootpath + "\\" + name))
{
sw.Write(richTextBox1.Text);
}