Example #1
0
        /// <summary>
        ///     Saves the Network Config to the specififed path
        /// </summary>
        /// <param name="path"></param>
        /// <param name="conf"></param>
        public static void Save(string path, NetworkConfig conf)
        {
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            var cs = new XmlSerializer(typeof(NetworkConfig));
            var fs = new FileStream(path, FileMode.Create);

            cs.Serialize(fs, conf);
        }
Example #2
0
        /// <summary>
        ///     Loads the Network Config from the specified path.
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static NetworkConfig Load(string path = "")
        {
            var ret = new NetworkConfig();

            if (!File.Exists(path))
            {
                return(ret);
            }
            var cs = new XmlSerializer(typeof(NetworkConfig));
            var fs = new FileStream(path, FileMode.Open);

            ret = (NetworkConfig)cs.Deserialize(fs);

            return(ret);
        }