Hi!
In your opinion what's the best way to write and read to a XML file if you want to insert random data to the file, like settings, and later on change, add or delete some of that data?
By best way I mean simple and few lines of code.
Printable View
Hi!
In your opinion what's the best way to write and read to a XML file if you want to insert random data to the file, like settings, and later on change, add or delete some of that data?
By best way I mean simple and few lines of code.
For settings, I go with My.Settings ... it doesn't get much simpler than that.
Or, if you need something a bit more flexible but simple... store everythign in a class and (de)serialize it... only takes a couple lines of code, and once you make a method out of it, it's just as easy to use as My.Settings.
-tg
My.Settings is very nice, but doesn't allow to add new settings in runtime.
Serializing/deserializing a class is very limited. If I want to serialize two different classes to the same XML I would need some kind of a workarround, like putting the 2 classes in another class. Well you see how messy that gets.
Isn't there anyway neater?
Found the solution here. LINQ to XML is very neat and easy to use.