HiveBrain v1.2.0
Get Started
← Back to all entries
snippetcsharpCritical

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

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
usernamenethowthecurrentusingget

Problem

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

Solution

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

Code Snippets

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

Context

Stack Overflow Q#1240373, score: 1078

Revisions (0)

No revisions yet.