简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM