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

cnet

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

Best Answer

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