public override void SaveToFile(string path)
{
//Check last modification
if (LastModification != DateTime.MinValue && File.Exists(path))
{
DateTime lastDateTime = File.GetLastWriteTime(path);
if (LastModification != lastDateTime)
{
throw new Exception("Unable to save the Output Device file. The file has been modified by another user.");
}
}
Name = Path.GetFileNameWithoutExtension(path);
XmlSerializer serializer = new XmlSerializer(typeof(OutputEmailDevice));
StreamWriter sw = new StreamWriter(path);
serializer.Serialize(sw, (OutputEmailDevice)this);
sw.Close();
FilePath = path;
LastModification = File.GetLastWriteTime(path);
}