简体   繁体   English

如何在Windows Service中为已登录用户查找appdata文件夹的路径

[英]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.

相关问题 在C#windows服务中获取appdata \\ local文件夹路径 - Get appdata\local folder path in C# windows service 作为系统帐户运行的 Windows 服务如何获取当前用户的 \AppData\Local\ 特殊文件夹? - How can Windows service running as System account get current user's \AppData\Local\ special-folder? 获取已登录用户的AppData \\ Local文件夹 - Get AppData\Local folder for logged user 通过在本地配置文件下运行服务,从Windows服务获取用户appdata路径 - Get user appdata path from windows service by running service under local profile Windows 服务启动进程外 COM 服务器 - CSIDL_APPDATA 作为不同的用户路径返回 - Windows Service launching Out of Process COM server - CSIDL_APPDATA returning as different user path 如何从Windows 8中的服务获取登录用户 - How to get logged in user from a service in windows 8 C# 如何获取用户 AppData 文件夹,而不是 AppData\Roaming? - C# How to get the User AppData folder, NOT AppData\Roaming? 如何找到已登录的Windows用户的会话名称? - How to find the session name of the logged in Windows user? 如何在 C# 中获取 Windows\system32\config\systemprofile\AppData\Local\ 文件夹路径? - How to get Windows\system32\config\systemprofile\AppData\Local\ folder path in C#? 获取当前登录用户的Documents文件夹路径 - Get Documents folder path of current logged on user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM