C#记事本怎么实现保存功能(区别于另存为的)
展开全部
private void 保存ToolStripMenuItem_Click(object sender, EventArgs e)
{
Save();
}
private void Save()
{
if (originFileName != "")
{
StreamWriter sw = new StreamWriter(originFileName);
sw.Write(richTextBox1.Text);
sw.Close();
origin = richTextBox1.Text;
}
else
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
originFileName = saveFileDialog1.FileName;
StreamWriter sq = new StreamWriter(saveFileDialog1.FileName);
sq.WriteLine(richTextBox1.Text);
sq.Close();
origin = richTextBox1.Text;
}
}
}
{
Save();
}
private void Save()
{
if (originFileName != "")
{
StreamWriter sw = new StreamWriter(originFileName);
sw.Write(richTextBox1.Text);
sw.Close();
origin = richTextBox1.Text;
}
else
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
originFileName = saveFileDialog1.FileName;
StreamWriter sq = new StreamWriter(saveFileDialog1.FileName);
sq.WriteLine(richTextBox1.Text);
sq.Close();
origin = richTextBox1.Text;
}
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询