In our current code, we indicate the path of configure file, and use "ExeConfigurationFileMap" to generate Configuration object:
var fileMap = new ExeConfigurationFileMap();
fileMap.ExeConfigFilename = GetAppSettingWithPathByName(key); //File path
var config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
Now, we change the strategy.I have read the content of configure file into a string object,how can I use the string object to generate Configuration object?
Thanks
Edit:
Just use
XDocument doc = XDocument.Load(path);
var yourtext = doc.ToString();
or more simple
File.ReadAllLines(path);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.