[英]How to find the path to appdata folder for the logged in user in windows service
I wrote a service and in the code I tried to get the AppData
folder's path: 我编写了一项服务,并在代码中尝试获取
AppData
文件夹的路径:
C:\Users\[Username]\AppData\
I tried: 我试过了:
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
But I got: 但是我得到了:
C:\Windows\system32\config\systemprofile\AppData
You're getting the AppData folder of the Account running the service. 您将获得运行该服务的帐户的AppData文件夹。 ( System Account ) There is no other user involved in it.
( 系统帐户 )没有其他用户参与其中。
If you want a particular user's AppData folder, run the Windows Service under that user's account. 如果要特定用户的AppData文件夹,请在该用户的帐户下运行Windows服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.