I have custom ConfigurationSection and call Configuration.Save() after some modifications against it:
var config = ConfigurationManager.OpenMappedExeConfiguration(
new ExeConfigurationFileMap() { ExeConfigFilename = "My.config" },
ConfigurationUserLevel.None);
if (config != null)
{
// do stuff
config.Save();
}
Currently it performs some formatting of resulting XML. For example, replaces tabs with spaces, inserts line-breaks if it thinks that it's too long (> ~130 characters), etc.
How can I preserve or control that?
Save function internally uses the
XmlUtilWriterclass which is also an internal class underSystem.Configurationnamespace. Your best change is to either try to modify the class with reflection at runtime, or go the easy way and do a serialization manually.