问题
How to add a new name in My.Settings?
So far, I've learned how to read and edit values in it, but how can I add another row/name at run-time?
Something like:
My.Settings.AddName.String("foo1")
My.Settings.Save()
My.Settings.foo1 = "fooNew"
I can't see such on the web.. Thanks
EDIT: will be used for the name,text and location of dynamically added buttons.
SeeThisLink
回答1:
The My.Settings
application settings are compiled into your assembly. The properties cannot be altered at runtime because of this. Expecting new settings to be available at runtime through the My.Settings
property will not be possible. You would need to resort to more rudimentary techniques like those highlighted by this MSDN question.
回答2:
You cannot do it at runtime with whats built into my.settings namespace, however its entirely possible. Id love to take credit for this but it has already been answered on stackoverflow.
As long as you know the file path and node name, you can build your own xml parser class to do whatever you want using this very simple example I couldn't write any more clearly:
How to programatically add nodes at certain locations in xml config file
来源:https://stackoverflow.com/questions/21199434/add-name-in-my-settings