Search code examples
.netservicespecial-folderssettings

Best place to store data / settings for a .net Service and a GUI Frontend


I have a program that runs as a service and also runs simultaneously as the service front end.

what is the best strategy for storing files and data for both these instances.

the program runs in 3 modes :-

  • Completely as a service
  • Service and front end GUI (ie 2 instances)
  • GUI

In all cases, files and configuration will need to have create / read / write access and accessible in every other mode

ApplicationData, LocalApplicationData, seem user specific, and i don't want the service to run under a user account

CommonApplicationData, i think has restrictions for general users under UAC

CommonProgramFiles ProgramFiles also has restrictions for general users under UAC

however with the last 2 examples there is the options of setting the permissions on install

Does anyone have an elegant solution to this, or can point me in the right direction

Thanks


Solution

  • The %ALLUSERSPROFILE% environment variable should suit your needs. It points to C:\Documents and Settings\All Users on WinXP and C:\ProgramData on modern Windows, both of which are for the storage of user-agnostic program data.