知道字符串和文本路径,实现文本读取到字符串,实现字符串写入到文本:
![](https://img-blog.csdnimg.cn/img_convert/1f6234e76430949325a49dd9cccbc040.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);
}