问题
In normal console app I have this
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 same path in both type of application?
回答1:
Remember that the services run under a different user profile (can be a LOCAL_SERVICE, NETWORK_SERVICE, etc.) If you'd like them to be the same, run the service under your user profile (You can specify this ServiceProcessInstaller.Account property when you create the installer, or in the Services manager of windows).
来源:https://stackoverflow.com/questions/4247581/net-windows-service-local-application-data-is-different-then-in-normal-app