直截了当的问题。如果CPU在序列化过程中崩溃,文件是否会损坏?
public bool TrySerializeToXML<T>(String FilePath, T t, XmlAttributeOverrides XmlAttributeOverrides = null)
{
lock (SerializationLock)
{
XmlSerializer Serializer = null;
try
{
if (XmlAttributeOverrides == null) Serializer = new XmlSerializer(t.GetType());
else Serializer = new XmlSerializer(t.GetType(), XmlAttributeOverrides);
using (TextWriter TextWriter = new StreamWriter(FilePath))
{
Serializer.Serialize(TextWriter, t);
}
}
catch
{
return false;
}
return true;
}
}