try
{
if (CheckChanged())
{
CurrenExcuse = new Excuse(random, selectedFolder);
UpdateForm(false);
}
}
catch (SerializationException)
{
MessageBox.Show("You excuse file was invalid.", "Unable to open a random excuse");
}
在处理异常的时候以上代码需要在最前面增加一句
using System.Runtime.Serialization;
可以在这个网页查询到相关信息:https://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationexception(v=vs.110).aspx