コード例 #1
0
        public static void SaveXmlConfig(DataSourceConfigItem model)
        {
            if (!File.Exists(dataSourceXmlConfigUrl))
            {
                File.Create(dataSourceXmlConfigUrl).Close();
            }
            XmlSerializer serializer = new XmlSerializer(typeof(DataSourceConfigItem));
            FileStream    fs         = new FileStream(dataSourceXmlConfigUrl, FileMode.Create);

            serializer.Serialize(fs, model);
            fs.Close();
        }
コード例 #2
0
        public static DataSourceConfigItem GetXmlConfig()
        {
            DataSourceConfigItem model = new DataSourceConfigItem();

            if (!File.Exists(dataSourceXmlConfigUrl))
            {
                return(model);
            }
            XmlSerializer serializer = new XmlSerializer(typeof(DataSourceConfigItem));

            try {
                string     fileName = dataSourceXmlConfigUrl;
                FileStream fs       = new FileStream(fileName, FileMode.Open);
                model = (DataSourceConfigItem)serializer.Deserialize(fs);
                fs.Close();
            }
            catch { }
            return(model);
        }