Click here to Skip to main content
15,886,067 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
How can i get current Windows XP username through c# code?
Posted

 
Share this answer
 
Comments
RAJI @Codeproject 5-May-11 5:50am    
thanks!!!
Kim Togo 5-May-11 5:52am    
You are welcome. Remember to "Accept Answer" :-)
Try:
string name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
This will return the domain and user name as a string.
 
Share this answer
 
Comments
Kim Togo 5-May-11 6:21am    
Good answer, my 5. With this you can do some advanced stuff.
u can use

C++
Environment.UserName


in ur c# code to get username.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900