我試圖抓住我的形式結束,這樣,當用戶退出時,它節省了「用戶已退出」到一個文本文件,這是我的代碼:錯誤捕獲接近C#
private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (String.IsNullOrEmpty(directory))
{
Close();
e.Cancel = false;
}
else
{
string time = DateTime.Now.ToString("hh:mm");
TextWriter msg = new StreamWriter(directory, true);
msg.WriteLine(" (" + time + ") == " + uName + " Has Left The Chat == ");
msg.Close();
Close();
e.Cancel = false;
}
}
我的問題是,我得到這個錯誤:
"Make sure you do not have an infinite loop or infinite recursion"
有關如何解決此問題的任何想法?
請仔細閱讀http://meta.stackexchange.com/questions/10647/how-do-i-write-a-good-title – 2013-04-22 05:55:43
關閉會提高'formClosing'事件,所以你在這裏再次調用 – V4Vendetta 2013-04-22 05:56:40