Where should the Windows service exist on the file system?

I am writing a Windows service that should save some data during a reboot / reboot of a service. I am currently writing files in the directory returned Application.UserAppDataPath, but this does not seem to give me a consistent answer. How to determine the right place to record data?

+5
source share
3 answers

It depends on whether your service is running with a system account or with a specific user account.

  • System . Store the files in the CommonApplicationData folder:

    string pathForSystem = Environment.GetFolderPath (Environment.SpecialFolder.CommonApplicationData);

  • . ApplicationData:

    string pathForUser = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

+4

, ( ), Application.CommonAppDataPath.

+4

If this is a .NET service, I think you could use IsolatedStorage

0
source

All Articles