获取用户目录的路径 [英] Obtaining path of users directory

查看:123
本文介绍了获取用户目录的路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从MS Vista中的Windows服务获取Users文件夹的路径?
我想到 C:\Users 目录的路径,但是它可能是不同的位置取决于系统本地化。

How to get path of Users folder from windows service on MS Vista? I think about path of C:\Users directory, but it may be different location depend on system localization.

推荐答案

查看 Environment.SpecialFolder枚举,例如

 Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);

调整所需的特殊文件夹。但是,在阅读另一篇文章时,此处,看起来你可能需要对字符串进行一些操作,如果你想要确切地 c:\users 而不是 c:\users\public ,例如。

Adjust for the special folder you want. However, in reading another post found here, it looks like you may need to do a little manipulation of the string if you want exactly c:\users instead of c:\users\public, for example.

这篇关于获取用户目录的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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