public void Save() { config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); CustomSection customSection; if (config.Sections[name] == null) { // セクションが無い場合は作成し、追加する。 customSection = new CustomSection(); customSection.WINDOWPLACEMENTtoXML(Placement); config.Sections.Add(name, customSection); } else { // セクションが存在する場合は読み込む。(追加するとエラー) customSection = (CustomSection)config.Sections[name]; customSection.WINDOWPLACEMENTtoXML(Placement); } customSection.SectionInformation.ForceSave = true; if (!customSection.ElementInformation.IsLocked) { config.Save(System.Configuration.ConfigurationSaveMode.Full); } }
public void Reload() { config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None); CustomSection customSection = new CustomSection(); if (config.Sections[name] == null) { } else { customSection = (CustomSection)config.Sections[name]; Placement = customSection.XMLtoWINDOWPLACEMENT(); } }