Wednesday, August 22, 2007

How to find the system directory (and other environement variables)

Was looking through the msdn Forums recently and someone was asking how to get the system path to save some files... and I though hmm this sounds like a job for the my namespace.... Alas I was wrong, my.computer could not help me but then it struck me... The system.enviroment class could help. Here are some of the goodies in this class:

CurrentDirectory
Returns and sets the fully qualified path of the current directory; that is, the directory from which this process starts.

MachineName
Returns the NetBIOS name of this local computer.

OSVersion
Returns an OperatingSystem object that contains the current platform identifier and version number.

SystemDirectory
Returns the fully qualified path of the system directory.

UserDomainName
Returns the network domain name associated with the current user.

UserName
Returns the user name of the person who started the current thread.

Version
Returns a Version object that describes the major, minor, build, and revision numbers of the common language runtime.

WorkingSet
Returns the amount of physical memory mapped to the process context.

e.g
me.text = System.environment.systemdirectory

No comments: