Example #1
0
        public static void Load()
        {
            Main main = Main.Get();
            
            // try to load the config
            try
            {
                Config c = Deserialize(Program.BasePath + "/config/studio.xml");

                main.config = c;

                main.LoadInterfaceSettings();
            }
            // something went wrong -> create a new config file
            catch (System.Exception)
            {
                main.WriteToConsole("Could not open config file, falling back to defaults.");

                Config c = new Config();

                main.config = c;

                // save the newly created cofig
                c.Serialize(Program.BasePath + "/config/studio.xml", c);
            }
        }
Example #2
0
        private void Serialize(string file, Config config)
        {
            // make sure the config directory exists
            if (!System.IO.Directory.Exists(Program.BasePath + "/config"))
            {
                System.IO.Directory.CreateDirectory(Program.BasePath + "/config");
            }

            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(Config));

            System.IO.StreamWriter writer = System.IO.File.CreateText(file);
            
            xs.Serialize(writer, config);

            writer.Flush();
            writer.Close();
        }