none
How to get the folder name of C:\Users\[USER]

    Question

  • How to get the folder name of C:\Users\[USER]

    i want to get the [USER] folder where the DOCUMENTS folder is located. please help.
    Monday, April 24, 2017 10:22 PM

All replies

  • How to get the folder name of C:\Users\[USER]

    i want to get the [USER] folder where the DOCUMENTS folder is located. please help.

    Are you looking for CSIDL_PROFILE or CSIDL_PERSONAL perhaps?

    https://msdn.microsoft.com/en-us/library/windows/desktop/bb762494(v=vs.85).aspx

    Dave

    Monday, April 24, 2017 10:50 PM
  • Hi StarBoy08,

    What do you want to do?

    Please provide more information about your issue.

    Best regards,

    Joyce


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, April 27, 2017 6:37 AM
  • In which language ?

    For example, in C# :

    string sPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

    Thursday, April 27, 2017 6:59 AM
  • Hi StarBoy08,

    The code you are looking for is (in c#) -

    sPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

    It will return you the folder name in 'C:\Users\[USER]' format.

    Tried and tested.

    Thank you,

    Sovan


    Thursday, April 27, 2017 8:54 AM
  • sPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);

    will be more accurate as per the question.

    Thursday, April 27, 2017 8:55 AM