请问大家c#窗体设计菜单打开文件功能时打不开想要打开的文件是为什么
代码
private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{
fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);//获取文件位置
richTextBox.LoadFile(fileName + @"\tt.txt");
}
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
fileName = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);//获取文件位置
richTextBox.SaveFile(fileName + "\tt.txt");
}
这样写
OpenFileDialog ofn = new OpenFileDialog();
if (ofn.ShowDialog() == DialogResult.OK)
richTextBox.LoadFile(ofn.FileName);