Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Load Configuration from string

I want to create a Configuration object from an xml string or stream rather than a file. But as far as I can see, the ConfigurationManager requires a file path to instantiate a Configuration object. Does anyone know a way of creating a Configuration object from something other than a file?

like image 783
JacquesB Avatar asked Dec 13 '25 14:12

JacquesB


1 Answers

Just save the stream to a file using System.IO and load it with

ConfigurationManager.OpenMappedExeConfiguration(new ExeConfigurationFileMap(filename))

Documentation

http://msdn.microsoft.com/en-us/library/system.configuration.configurationmanager.openmappedexeconfiguration(v=VS.90).aspx

like image 190
smartcaveman Avatar answered Dec 16 '25 14:12

smartcaveman