我想寫記事本,我怎麼知道用戶點擊'取消'?我的代碼無法正常工作:用C保存文本文件#
private void SaveAsItem_Click(object sender, EventArgs e)
{
saveFileDialog1.FileName = "untitled";
saveFileDialog1.Filter = "Text (*.txt)|*.txt";
saveFileDialog1.ShowDialog();
System.IO.StreamWriter SaveFile = new System.IO.StreamWriter(saveFileDialog1.FileName);
SaveFile.WriteLine(richTextBox1.Text);
SaveFile.Close();
if (DialogResult == DialogResult.Cancel)
{
richTextBox1.Text = "CANCEL";
issaved = false;
}
else
{
issaved = true;
}
}