Thursday, March 22, 2007

How to get the machine name, user name, OS etc. in .net?

Simple one., but worth mentioning it... How to get the machine name, user name, OS etc. in .net?

Use of System.Environment!


This Class is used to get the information about current logged in user in the Windows. that is this class will get all the information about the current user in the windows. it is also used to get the info about the Machine and its Harddrive and other information.

Frequently used Methods and Properties
System.Environment.UserName - To get the Current logged in user name and his ID.
System.Environment.Version - To get the Current Version of CLR
System.Environment.UserDomainName - To get the Domain Naem associated with the current user.
System.Environment.SystemDirectory - Fully Qualified Path of SYS. Directory
System.Environment.OSVersion - To get the OS version
System.Environment.MachineName - To get the Machine name
System.Environment.GetLogicalDrives() - To get the Logical Drives of the Computer
System.Environment.Exit - To Exit the Current Process
There are lot of properties and functions available apart from this, please browse through in .net.

Cheers - Dipesh

No comments: