This is a more vague question than you understand. "Settings" can include many things.
There is a good .NET framework for handling application settings in configuration files. They are typically exposed to your program as properties of a global settings object; classes in the System.Configuration namespace will take care of reading and saving them, and Visual Studio has tools that automatically generate code to work with them. One of the data types supported by this framework is StringCollection , so you can use this to store a list of servers.
But for a large list of servers, this is not my first choice for several reasons. I would expect that the elements in your list are actually tuples (e.g. hostname, port, description), and not simple strings, in which case you will have to format and parse the data to get it in a StringCollection , and this is usually a sign that you should be doing something else. In addition, the application’s settings are read-only (at least in Vista), and although you can customize the user area to be stable, it will lead you to a path that you probably want to understand before committing .
So, one more thing I would think: Is your server list just a list or do you have an internal object model representing it? In the latter case, I might consider using XML serialization to store and retrieve objects. (The only thing I saved in the application configuration file will be the path to the serialized object.) I would do this because serializing and deserializing simple objects in XML is very simple; You don’t need to design and test the correct serialization format, because the tools do it for you.
The main reason I look at using a database is because my program performs many operations whose results should be atomic and durable, or if for some reason I do not want all my data in memory at once. If every time X happens, I need a persistent record that leads me towards using the database. You do not want to use XML serialization for something like this, as a rule, because you cannot realistically serialize only one object if you save all your objects in one physical file. (Although it’s certainly not crazy to just serialize your entire object model in order to save one change. In fact, this is exactly what my company product does, and this points to another circumstance in which I would not use the database: if the data schema changes frequently).
source share