Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing C# Service Settings in Windows & Mono

I'm writing a C# service that I want to be able to use on Windows and Mono. I've just started experimenting with Mono and am trying to determine the best way to store settings to control the service that works for both Windows and Mono.

  1. Settings file where service is installed

    • Pros: Same code for each platform, easy to find for editing
    • Cons: Permissions, Windows probably won't like writing to the file
  2. Settings file in platform storage (%APPDATA, /etc, ...)

    • Pros: Will have permissions, easier to find for editing
    • Cons: More coding required to handle each platform
  3. Small database (SQLite maybe?)

    • Pros: Easier to write code to store and retrieve settings
    • Cons: Not easy to edit manually, same problem of where to store

Which do you think is the best, or do you have a better suggestion?
I will also probably be writing a command line client to allow for easier changing of settings, will this change how settings should be stored?

like image 393
Samuel Avatar asked Apr 23 '09 00:04

Samuel


People also ask

What is storing in C?

A storage class defines the scope (visibility) and life-time of variables and/or functions within a C Program. They precede the type that they modify. We have four different storage classes in a C program − auto. register.

What is the storage class in C?

There are primarily four storage classes in C, viz. automatic, register, static, and external.

What is stored value in C?

In C programming float data type is used to store floating-point values. Float in C is used to store decimal and exponential values. It is used to store decimal numbers (numbers with floating point values) with single precision.


1 Answers

Take a look at IsolatedStorage. This is an API for providing you with per-application storage, it's built into .NET and is supported in Mono. The API provides you with file IO on files that are stored in a location managed by the framework: in Mono it'll be a ~/.isolatedstorage directory, in Windows it'll be somewhere in the user's Documents and Settings.

With this API, you can maintain your settings file without having to worry about operating system specifics or permissions.

like image 187
Ilya Haykinson Avatar answered Oct 05 '22 12:10

Ilya Haykinson