public static XMPPSettings ReadSettings()//(string filename)
        {
            if (File.Exists(filename))
            {
                XmlSerializer formatter = new XmlSerializer(typeof(XMPPSettings));

                using (StreamReader fs = new StreamReader(filename, Encoding.GetEncoding(1251), false))
                {
                    XMPPSettings settings = (XMPPSettings)formatter.Deserialize(fs);
                    fs.Close();
                    return(settings);
                }
            }
            else
            {
                XMPPSettings xMPPSettings = new XMPPSettings();
                xMPPSettings.Enable          = false;
                xMPPSettings.Server          = "127.0.0.1";
                xMPPSettings.Port            = 8080;
                xMPPSettings.Domain          = "domain.ru";
                xMPPSettings.AutoReconnect   = 100;
                xMPPSettings.User            = "******";
                xMPPSettings.Password        = "******";
                xMPPSettings.MessageTemplate = "У Вас новое уведомление!";

                XMPPConfig.SaveSettings(xMPPSettings);

                return(xMPPSettings);
            }
        }
        public static void SaveSettings(XMPPSettings settings)
        {
            XmlSerializer formatter = new XmlSerializer(typeof(XMPPSettings));
            TextWriter    writer    = new StreamWriter(filename, false, Encoding.GetEncoding(1251));

            formatter.Serialize(writer, settings);
            writer.Close();
        }