0

I have a Windows service that runs as a specific user (agent installed on desktop machines) - I had originally stored/updated appsettings.json in Program Files alongside the binary, but this causes issues during updates etc.

I have since moved to using an app config file under the users home directory - which I create manually (Finding local users profile path in C# and creation of folder).

I also see there is a ProgramData enum that is available via .NET directory enums, and would save the above code (less things to break in future).

The Linux/MacOS version of this software would be under /home/myuser or /etc/myapp. I need to consider this as I write an abstraction layer to run my BackgroundWorker as a daemon and the associated installation thereof.

My question is which is better to follow for this multi-platform supported app, store config files by user directory, or program data directory?

Appreciate this is on the fringes of development question, but also not necessarily serverfault question - if better suited let me know and will repost on a different site.

morleyc
  • 2,169
  • 10
  • 48
  • 108
  • I would suggest to containerize you app with .net 6. the world of docker containers is where you need to be :) – Sievajet Nov 19 '22 at 14:59
  • For any infra would agree, however this is for an agent installed on a user machine. I wouldnt want docker as a dependency. – morleyc Nov 19 '22 at 21:07
  • 1
    It depends? Basically, is the expectation that the settings would be shared between users? If yes, then it should be in program data. If not, under the user's. – ESG Nov 19 '22 at 22:56
  • Very pertinent and succinct. Put as you have, the answer is no, no sharing. The service user would only have access to that data, no one else. – morleyc Nov 19 '22 at 22:58

0 Answers0