示例#1
0
        public static void SaveSettings(UpdateSettings data)
        {
            string        fileName   = Application.StartupPath + @"\UpdateVer.xml";
            XmlSerializer serializer = new XmlSerializer(typeof(UpdateSettings));

            // serialize the object
            FileStream fs = new FileStream(fileName, FileMode.Create);

            serializer.Serialize(fs, data);
            fs.Close();
        }
示例#2
0
        public static UpdateSettings GetSettings()
        {
            UpdateSettings data       = null;
            XmlSerializer  serializer = new XmlSerializer(typeof(UpdateSettings));

            try
            {
                string     fileName = Application.StartupPath + @"\UpdateVer.xml";
                FileStream fs       = new FileStream(fileName, FileMode.Open);
                data = (UpdateSettings)serializer.Deserialize(fs);
                fs.Close();
            }
            catch
            {
                data = new UpdateSettings();
            }
            return(data);
        }