.net local service windows application data differs from regular application

In a regular console application, I have

Environment.SpecialFolder.LocalApplicationData is C: \ Users \ Simon \ AppData \ Local \

In windows service

Environment.SpecialFolder.LocalApplicationData is C: \ Windows \ system32 \ config \ systemprofile \ AppData \ Local \

How can I specify the same path in both types of applications?

+7
c # windows-services
source share
1 answer

Remember that services work under a different user profile (may be LOCAL_SERVICE, NETWORK_SERVICE, etc.). If you want them to be the same, start the service under your user profile (you can specify this ServiceProcessInstaller.Account property when creating the installer or in the Windows Service Manager).

+4
source share

All Articles