private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
{
DialogResult UserResponse = new DialogResult();
if (txtPage.Modified)
{
UserResponse = MessageBox.Show("Your document has changed since the last save. \n\n Would you like to save?", "Warning", MessageBoxButtons.YesNoCancel);
}
if (txtPage.Modified & UserResponse == DialogResult.Cancel)
{
e.Cancel = true;
}
else if (txtPage.Modified & UserResponse == DialogResult.Yes)
{
if (!(SaveFile()))
{
e.Cancel = true;
}
}
Properties.Settings.Default.Content = txtPage.Text;
if (FileName != "")
{
Properties.Settings.Default.LastFileName = FileName;
}
Properties.Settings.Default.Save();
CacheFile();
}