Only load if file exists, and make sure file path exists on save

This commit is contained in:
Michael Becker 2014-06-26 18:41:21 -04:00
parent 7aac63b557
commit 5d3e79c04b

View File

@ -47,13 +47,24 @@ namespace UniversalEditor.UserInterface
public void Load()
{
UniversalEditor.DataFormats.PropertyList.XML.XMLPropertyListDataFormat xdf = new DataFormats.PropertyList.XML.XMLPropertyListDataFormat();
Document.Load(mvarLocalConfiguration, xdf, new Accessors.FileAccessor(Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Configuration.xml"));
string FileName = Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Configuration.xml";
if (System.IO.File.Exists(FileName))
{
Document.Load(mvarLocalConfiguration, xdf, new Accessors.FileAccessor(FileName));
}
}
public void Save()
{
UniversalEditor.DataFormats.PropertyList.XML.XMLPropertyListDataFormat xdf = new DataFormats.PropertyList.XML.XMLPropertyListDataFormat();
Document.Save(mvarLocalConfiguration, xdf, new Accessors.FileAccessor(Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Configuration.xml", true, true));
string FileName = Engine.DataPath + System.IO.Path.DirectorySeparatorChar.ToString() + "Configuration.xml";
string dir = System.IO.Path.GetDirectoryName (FileName);
if (!System.IO.Directory.Exists(dir))
{
System.IO.Directory.CreateDirectory(dir);
}
Document.Save(mvarLocalConfiguration, xdf, new Accessors.FileAccessor(FileName, true, true));
}
}
}