.net windows service local application data is different then in normal app

一世执手 提交于 2019-12-04 00:18:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!