Пример #1
0
        public void Save(string fileName = "Settings.txt")
        {
#if WINDOWS
            using (var stream = new FileStream(fileName, FileMode.OpenOrCreate))
#else
            using (var stream = LocalStorageExtensions.OpenStreamForWrite(fileName, CreationCollisionOption.ReplaceExisting))
#endif
            {
                using (StreamWriter sw = new StreamWriter(stream))
                {
                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(_settings.GetType());
                    serializer.WriteObject(sw.BaseStream, _settings);
                }
            }
        }