NB: The answer in this question is out of date.
So, I have a save dialog box:
...
SaveFileDialog sfd = new SaveFileDialog();
sfd.ShowDialog();
// SaveFileDialog.[Whatever] - Init code basically.
if (sfd.DialogResult == DialogResult.OK)
{
// Definitely do something.
Console.Print("File selected.");
}
if (sfd.DialogResult == DialogResult.Abort)
{
// Maybe the opposite of the above?
Console.Print("File selection Cancelled");
}
if ( ... ) { }
and so on.
But... SaveFileDialog.DialogResult
has been replaced by events instead...
And that the only available events are SaveFileDialog.FileOK
, SaveFileDialog.Disposed
and SaveFileDialog.HelpRequest
.
How do I trigger an event (or move to a line of code) based when the user clicked Cancel rather than completing it (Clicking Save)?
I'm looking to branch based on whether the user cancels or successfully selects the file location to save to.