Need to get UserProfile name in C# code on Azure Windows server
Budget: $10 – $30 USD
Within a C# app I need to get the current user name for an Azure Windows VM. I need the path for the current user, like - c:\Users\my_user_name\Desktop.
The following methods work in development on a Windows 10 machine but not on an Azure Windows Virtual Machine.
Environment.UserName
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
On Azure VM-
C:\windows\system32\config\systemprofile
is returned when using either -
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
The following methods work in development on a Windows 10 machine but not on an Azure Windows Virtual Machine.
Environment.UserName
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
Environment.GetFolderPath(Environment.SpecialFolder.Desktop))
On Azure VM-
C:\windows\system32\config\systemprofile
is returned when using either -
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
Environment.GetFolderPath(Environment.SpecialFolder.Desktop))