In this article, I will tell you 3 different ways which you can use to get the User Name. Try any of the following method to get User name of currently logged in user in your Computer.
Introduction:
- Using Environment Class
Environment.UserName - Using SystemInformation Class
System.Windows.Forms.SystemInformation.UserName - Using WindowsIdentity Class
string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
Here is the snapshot of MessageBox showing output of these three methods ![]()
Incoming search terms:
- c# use google login (1)
- getusername c# (1)
- list of users connected to server using c# code (1)
- windows connected user c# web (1)