예제 #1
0
파일: App.xaml.cs 프로젝트: baughj/Spark
        static void SaveUserSettings(string fileName, UserSettings settings)
        {
            if (fileName == null)
                throw new ArgumentNullException("fileName");

            if (settings == null)
                throw new ArgumentNullException("settings");

            try
            {
                var xml = new XDocument(
                    new XDeclaration("1.0", "utf-8", "yes"),
                    new XElement("Settings",
                        new XAttribute("FileVersion", App.SettingsFileVersion),
                        settings.Serialize()));

                // Save user settings to file
                xml.Save(fileName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(string.Format("Unable to save user settings: {0}", ex.Message));
            }
        }