openFiledialog cancel event – .NET Framework

  .net

Q(Question):

Hallo everyone,

Iam using a openFiledialog to open when a click a button. If i click the cancel button in the openFiledialog how can capture that event ?..

Thank you.

A(Answer):

@sarabonn

Try this


System.Windows.Forms.DialogResult myResult;
myResult=openFileDialog1.ShowDialog();
int i = Convert.ToInt32(DialogResult.Cancel);
if (myResult==DialogResult.Cancel)
{
MessageBox.Show("Specify file");
}

LEAVE A COMMENT