public static void SaveConfig()
{
lock (ThreadLock)
{
string fileName = Program.AppDataPath + @"XML\config.xml";
//save configuration
var s = new XmlSerializer(typeof(configuration));
var sb = new StringBuilder();
using (var writer = new StringWriter(sb))
{
try
{
string pwd = _conf.WSPassword;
//save the encrypted form
if (!string.IsNullOrEmpty(_conf.WSPassword))
{
_conf.WSPassword = EncDec.EncryptData(_conf.WSPassword, "582df37b-b7cc-43f7-a442-30a2b188a888");
_conf.WSPasswordEncrypted = true;
}
else
{
_conf.WSPassword = "";
_conf.WSPasswordEncrypted = false;
}
s.Serialize(writer, Conf);
//revert to clear text for in memory lookups
_conf.WSPassword = pwd;
File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
}
catch (Exception e)
{
Logger.LogExceptionToFile(e);
}
}
}
}