kch4416
kch4416

Reputation: 31

How to know user close open dialog without saving?

SaveFileDialog sfd = new SaveFileDialog();

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

Upvotes: 0

Views: 62

Answers (2)

Viva
Viva

Reputation: 2075

if (sfd.ShowDialog() == DialogResult.OK){

  //user  saved it
}
else {

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

Upvotes: 3

Dmitry
Dmitry

Reputation: 14059

Use a return value from sfd.ShowDialog():

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

Upvotes: 2

Related Questions