9

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?

Samuel
  • 37,778
  • 11
  • 85
  • 87

1 Answers1

5

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.

Ilya Haykinson
  • 569
  • 4
  • 7
  • Had no idea IsolatedStorage was implemented in Mono. Looks like SQLite ADO.NET has IsolatedStorage support planned. – Samuel Apr 23 '09 at 01:17
  • IsolatedStorage doesn't seem to allow sharing of a store across multiple projects. That kind of kills what I want to do. It also dies if you move the assembly. – Samuel Apr 23 '09 at 02:09
  • Are you sure? What if you request the isolated storage store for IsolatedStorageScope.User? I haven't tried this, but it may work... – Ilya Haykinson Apr 23 '09 at 23:46