Getting Computer Name and Computer User Name in C# Projects


Sajjad Arif Gul - April 28, 2015 - 2 comments

I was working on a small project in which i was trying to get the User account name and User Computer Name on windows form so i tried some codes & in last i came up with this code. It gives System Name and System User Name. By this code you can get computer identification in your simple projects.

For Computer Name

Console.WriteLine(System.Environment.MachineName);

Output :

For User Account Name

Console.WriteLine(System.Security.Principal.WindowsIdentity.GetCurrent().Name.ToString());

Output :

Author avatar

Sajjad Arif Gul

http://sajjadgul.com
Hi! I am Sajjad Arif Gul, Software Engineer, Web & Mobile Developer from Karachi Pakistan. I love sharing my knowledge that could possibly help someone’s life in some capacity. Happy Coding.

Related posts

2 comments

  1. yar app ki website load honay may 10 mint lety hai…???
    Slove Problem. 🙁

  2. Tumhara net slow hy bachy… :p

Post a Comment

Your email address will not be published. Required fields are marked *