locked
How do I delete entries from machine.config? RRS feed

  • Question

  • I'm trying to share information between a windows service app, and a windows forms app that configures the service.  I want to store a list of settings, and have to ability to add and remove items from this list.  

    I decided to use the machine configuration to store this information as it will be shared among multiple apps.  I created classes which derive from ConfigurationSection, ConfigurationElement, and ConfigurationElementCollection.

    My problem is that I cannot seem to delete any items from my collection.  If I call ConfigurationElementCollection.BaseRemove, it seems to mark the item as removed, but the Count property stays the same.  If I then call Configuration.Save(ConfigurationSaveMode.Full).  It doesn't remove the item from machine.config.

    Am I doing something wrong?
    Friday, October 24, 2008 2:25 PM

Answers

  • You could open your machine.config file as a XmlDocument and delete the node(s) you want.
    • Marked as answer by Zhi-Xin Ye Friday, October 31, 2008 9:48 AM
    Friday, October 31, 2008 9:05 AM