How do I get the current username in .NET using C#?
Get the current Windows username:
using System; class Sample { public static void Main() { Console.WriteLine(); // <-- Keep this information secure! --> Console.WriteLine("UserName: {0}", Environment.UserName); } }