c# - How to create a modified copy of machine.config file? -


i want add/remove/upsert line ado .net data provider programmatically c#.

my first thought parse file parser (like eto.parse), add/remove necessary span of text , write new file install image directory (which not write protected unlike write protected main machine.config).

then think, file xml, , possible use existing xml machinery instead of custom parser. load xml, build object model xml, modify , serialize.

then realise, object model working configs present in system.configuraion namespace.

and decide search existing example on how modify machine config these classes. found example how obtain it's location new configurationfilemap().machineconfigfilename; (see the best way path machine.config of different .net version)

just tell configmanager looking edit other current app's config file.

configuration config = configurationmanager.openmachineconfiguration();  

the, can use config.sections[whatever] access specific sections.

keep in mind config object maps out of properties attempting tweak, you'll need dig through specific section's interface find you're trying mess-up update.


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -