private void CopyConfigElement(IConfigurationElement fromSection, IConfigurationElement toSection) { foreach (IConfigurationSection fromChild in fromSection.GetChildren()) { IConfigurationSection toChild = toSection.CreateSection(fromChild.Key, fromChild.Type); if (fromChild.Type != SectionType.Object) { toChild.Set(fromChild.Get()); } else { CopyConfigElement(fromChild, toChild); } } }