Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I Store Program Settings?

I am creating a desktop app that will sit on a PC and occasionally check a web server for updates to various settings.

The program will be using these settings frequently so I would like cache the settings in a file on the PC so it doesn't have to hit the server constantly. There are a lot of settings. I was thinking about storing them in an XML file but I need the file to be unreadable by the PC users.

How should I store the settings on the PC that the program can read and write to but the user cannot read?

EDIT: Sorry guys. The application is being written in C# using .NET 2.0. The application will only run on Windows. It is a console app that will run as a Windows Service.

like image 739
modernzombie Avatar asked Sep 15 '26 12:09

modernzombie


2 Answers

Assuming that you are targeting the Windows platform, you can either

  • use the registry
  • use a configuration file
  • or use a database

Data can be encrypted in all 3 cases if needed. If you really have lots of settings, the registry is probably not the easiest way to do this. If you have a .net app, look at SQL Server Compact Edition, it is really light-weight, easy to deploy with your app, and does not need a runtime environment.

like image 192
cdonner Avatar answered Sep 17 '26 01:09

cdonner


If the app is a service then it can run under an account that isn't the user's; then it's easy enough to keep the file hidden from him.

As a Windows app, you have your choice of the Registry or a file or a local database. For files, your choice of a simple properties file or an XML file.

For any of those, your choice of encrypted (just in case) or not.

like image 45
Carl Smotricz Avatar answered Sep 17 '26 00:09

Carl Smotricz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!