获得在C#窗口服务appdata\local文件夹路径 [英] Get appdata\local folder path in C# windows service

查看:2214
本文介绍了获得在C#窗口服务appdata\local文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让 C:\Users\<用户名> \AppData\Local 使用

Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

在C#的Windows服务,但它会返回一些其他的路径

in a C# Windows service, but it returns some other path

C:\Windows\ServiceProfiles\LocalService\AppData\Local

任何是否有任何想法如何做是正确的?

Does any have any idea how to do it correctly?

推荐答案

您运行在用户帐户下的服务?如果没有,你看该服务将使用自己的个人资料。如果此服务被登录的用户,那么你可以在文件夹传递给服务和旁路当地检查。否则,尝试运行在用户帐户下的服务(或为它创建一个帐户)。

Are you running the service under a user account? If not, the service will use its own profile as you see. If this service is "logged into" by a user, then you could pass the folder to the service and bypass local checking. Otherwise, try running the service under a user account (or create an account for it).

这篇关于获得在C#窗口服务appdata\local文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆