private void button2_Click(object sender, EventArgs e)
{
SaveFileDialog Sdialog = new SaveFileDialog();
Sdialog.ShowDialog();
Sdialog.FileOk += Sdialog_FileOk;
}
void Sdialog_FileOk(object sender, CancelEventArgs e)
{
try
{
StreamWriter FileProtocol = new StreamWriter(((SaveFileDialog)sender).FileName);
FileProtocol.Write(textBox3.Text);
FileProtocol.Close();
MessageBox.Show("File is write ok");
}
catch (Exception)
{
MessageBox.Show("Unknown Error. File is not write");
}
}
为什么事件 FileOk 不起作用?