I am currently working Open file and write file functions in C#. I am going through two problems: When the user is in the process of saving a file, if he/she exits the save dialog and nothing is saved I get an error(look at picture below for description). How can my program avoid this and not crash? and Is there away to display a message after the file has been saved?

private void button2_Click(object sender, EventArgs e)
{
SaveFileDialog saveReport = new SaveFileDialog();
saveReport.Filter = "Text Files | *.txt";
saveReport.ShowDialog();
StreamWriter writeFile = new StreamWriter(saveReport.FileName);
writeFile.Write(textBox1.Text);
writeFile.Close();
}
You could do something like this:
In principle the FileName will never be
nullor whitespace — the dialog prevents it unless you cancel, but I include it for clarity.