C# – How to get the current username in .NET using C#

.netc++

How do I get the current username in .NET using C#?

Best Solution

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;