Wednesday 11 June 2008

Getting the current User Name in Windows programming

Use this for getting the user name when building a windows application in DotNet. Done!
--------------------------------------------------

//
Place this at the top, above your namespace declaration
using System.Security.Principal;


//In a specific event, place the following.
string a;
a = System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString();

No comments:

Free Hit Counter