public static UserPrefs LoadPrefs(string file)
{
string settings = File.ReadAllText(file, Encoding.UTF8);
// test to see if it is an old AWB file
if (settings.Contains("<projectlang proj="))
throw new Exception("This file uses old settings format unsupported by this version of AWB.");
// check for empty settings file
if (settings.Trim().Length == 0)
{
MessageBox.Show("The settings file " + file + " is empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return (new UserPrefs());
}
settings = Regex.Replace(settings, @"<(/?)\s*SourceIndex>", "<$1SelectedProvider>");
XmlSerializer xs = new XmlSerializer(typeof(UserPrefs), new[] { typeof(PrefsKeyPair) });
return (UserPrefs)xs.Deserialize(new StringReader(settings));
}