Program Settings File

ImDaFrEaK

Well-known member
Joined
Jan 7, 2006
Messages
416
Location
California
Programming Experience
5-10
Not sure if this is the proper place to start this thread.

Question: What is the proper or most common way of saving program settings?

I know you can add a Settings file to your project and save Application Level Constants and User Scope variables of various sorts but is this the only or best way? I currently have a program that runs on each user account. Each account saves information to "Application.StartupPath & "/" & Application.UserName" I don't want to use the My Namespace b/c this will act as a windows service so to speak. Anyways, the users activity is saved there. This is what I want to do.

  1. Insure the program does not run on any account if not unlocked (serial key entered).
  2. Have the program run under certain propertys set at the Admin level for all users. (Such as a certain message on a startup banner)
Now I have the program working for the most part. I am simply writing my properties to file via the Admin side and when ran on the users side it reads out that property's file. The file is saved in the Application.StartupPath Directory. I know this works but is it now the most appropriate and efficient method? I am simply curious; I wish the "Settings files that you can add to the projects held more than constants at the Application Scope level. That would be my answer if it did.
 
If you're not going to use My.Settings then, in my opinion, the best way to save and load settings is to define a class with a property that corresponds to each setting and then simply serialise and deserialize an instance of this class to save and load the settings. If you want the serialised settings to be human-editable then use XML serialisation, otherwsie use binary. Serialisation takes about four lines of code no matter the complexity of the object. If the object is too complex you may have to add custom serialisation to the class itself, but the act of serialising or deserialising is still very simple.
 
If you're not going to use My.Settings then, in my opinion, the best way to save and load settings is to define a class with a property that corresponds to each setting and then simply serialise and deserialize an instance of this class to save and load the settings.

Incase you go that route, here's a -large- thread we just went through to get a simliar application running for a member using Binary Serialization.

http://www.vbdotnetforums.com/showthread.php?t=14660

Many good questions were asked and answered in there.
 
Ok, np there b/c that's the exact method I am doing now. Just didn't know if it was optimal. Thanks again and now i feel more comfortable about how im doing it.
 
Back
Top