/// <summary> /// Saves the settings file at the path specified within the settings document. /// </summary> /// <param name="settings">The settings to save.</param> /// <param name="exception">If the document could not be saved, this returns the /// resulting exception information.</param> /// <returns>Returns true if the file was successfully saved.</returns> public override bool SaveSettings(WritableSettings settings, out Exception exception) { Param.RequireNotNull(settings, "settings"); exception = null; if (settings.Path == null || settings.Contents == null) { throw new InvalidOperationException(Strings.SettingsFileHasNotBeenLoaded); } // Write the new settings to the document. XmlDocument document = settings.WriteSettingsToDocument(this); try { // Save the file. document.Save(settings.Path); // Update the write time. settings.WriteTime = File.GetLastWriteTime(settings.Path); return true; } catch (IOException ioex) { exception = ioex; } catch (SecurityException secex) { exception = secex; } catch (UnauthorizedAccessException unauthex) { exception = unauthex; } catch (XmlException xmlex) { exception = xmlex; } return false; }
public override bool SaveSettings(WritableSettings settings, out Exception exception) { Param.RequireNotNull(settings, "settings"); exception = null; if ((settings.Path == null) || (settings.Contents == null)) { throw new InvalidOperationException(Strings.SettingsFileHasNotBeenLoaded); } XmlDocument document = settings.WriteSettingsToDocument(this); try { document.Save(settings.Path); settings.WriteTime = File.GetLastWriteTime(settings.Path); return true; } catch (IOException exception2) { exception = exception2; } catch (SecurityException exception3) { exception = exception3; } catch (UnauthorizedAccessException exception4) { exception = exception4; } catch (XmlException exception5) { exception = exception5; } return false; }