Obtaining path of users directory

前端 未结 5 649
小蘑菇
小蘑菇 2021-01-18 18:43

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 sys

5条回答
  •  耶瑟儿~
    2021-01-18 19:11

    System.Environment.SpecialFolder will give you access to all these folders that you want, such as My Documents, Etc..

    If you use the UserProfile SpecialFolder, that should give you the path to your profile under Users.

    string userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
    

提交回复
热议问题