Obtaining path of users directory

前端 未结 5 604
小蘑菇
小蘑菇 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:03

    Take a look at the Environment.SpecialFolder Enumeration, e.g.

     Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory);
    

    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.

提交回复
热议问题