资源介绍
c#编写的简单记事本程序,private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (richTextBox1.Modified == true)
{
DialogResult dr = MessageBox.Show("要保存正在編輯的文件嗎?", "保存文件", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
//filename = saveFileDialog1.FileName;
{
StreamWriter st = new StreamWriter(saveFileDialog1.FileName);
st.Write(richTextBox1.Text);
st.Close();
richTextBox1.Clear();
}
}
if(dr==DialogResult.No)
{
richTextBox1.Clear();
}
}