Link to home
Start Free TrialLog in
Avatar of LeighWardle
LeighWardleFlag for Australia

asked on

What is the best way using vb.net to save settings on a per application and per user/application basis?

Hi Experts,

What is the best way using vb.net to save settings on a per application and per user/application basis?

One additional contraint is that I would to initialize some of the settings using my installer program, Setup Factory for Windows.

Thanks,

Regards,
Leigh
SOLUTION
Avatar of Raghu Mutalikdesai
Raghu Mutalikdesai
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"Best" is a subjective term, so you would have to define what best means to you.

.NET applications have the Settings file which you can set either user-level or application-level settings. Just go to Project->Properties->Settings Tab. On that tab you will see a grid for entering in your various settings. The third column is a scope column where you can set whether the property is for the user or for the application:

User generated image
User-scoped settings end up in an XML file that is in the user's profile directory; application settings end up in the application config file (in the same directory as the application). Don't be fooled:  While the application config file will show your user-scoped setting, this is more of a default value that will be provided to new users of your app. The actual value that is set for the individual users is stored in each user's profile directory.

You could use the registry as Raghu suggests in his second point, but .NET leans toward XML configuration files versus using the registry. You can still access the registry in .NET, but it's not the preferred place to store configuration.

You could also use a database, but this more of a heavyweight solution. There's nothing wrong with using a database, but just be sure you plan out the database carefully so that if you ever have to make changes they won't cripple your application unnecessarily.
Avatar of LeighWardle

ASKER

Thanks, Raghu and kaufmed, for your suggestions.

I will go with XML files.

Just a few questions:

1.

Can you point me to a sample project that shows how to manipulate XML settings in code?

2.

Where is the user's profile directory on Windows 7 or later?
Thanks,

Regards,
Leigh
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, Raghu and kaufmed, for your suggestions.

kaufmed - I really appreciate your detailed advice.

Regards,
Leigh