How to know user close open dialog without saving?

67 Views Asked by At
SaveFileDialog sfd = new SaveFileDialog();

sfd.ShowDialog();
sfd.Filter("Wave Files|*.wav");
ss.SetOutPutToWaveFile(sfd.FileName);
ss.Speak(richTextbox.Text);
ss.SetOutputToDefaultAudioDevice();
2

There are 2 best solutions below

0
Dmitry On BEST ANSWER

Use a return value from sfd.ShowDialog():

if (sfd.ShowDialog() == DialogResult.OK)
{
    // File was selected
}
else
{
    // Cancelled
}
1
Viva On
if (sfd.ShowDialog() == DialogResult.OK){

  //user  saved it
}
else {

   //write code to handle the case when an user does't save , and canceled it
}