Environment class: Provides information about the current environment and platform and how to manipulate them. This class cannot be inherited.
Namespaces: System
Assembly: mscorlib.dll
Inheritance Relationship:
Common Properties (Fields) and methods:
CurrentDirectory Gets or sets the fully qualified path of the current working directory
OSVersion gets the OperatingSystem object that contains the current platform identifier and version number.
GetLogicalDrives returns an array of strings containing the names of logical drives in the current computer.
GetFolderPath (environment.specialfolder) Gets the path to the System special folder identified by the specified enumeration.
Environment.SpecialFolder enumeration: Specifies the enumeration constants that are used to retrieve the directory path of the system special folder.
Namespaces: System
Assembly: mscorlib.dll
Commonly used special folder enumeration values:
Desktop logical desktops, not physical file system locations.
Programs contains a directory of user program groups.
ProgramFiles the "Program Files" directory.
More enumeration values See MSDN
Example:
1 usingSystem;2 3 classApp4 {5 Static voidMain ()6 {7 Console.WriteLine (environment.currentdirectory);8 Console.WriteLine (environment.osversion);9 Console.WriteLine (Environment.getfolderpath (Environment.SpecialFolder.Desktop));Ten Console.WriteLine (Environment.getfolderpath (Environment.SpecialFolder.Programs)); One Console.WriteLine (Environment.getfolderpath (Environment.SpecialFolder.ProgramFiles)); A - varDrivers =environment.getlogicaldrives (); - foreach(varDinchdrivers) the { - Console.WriteLine (d); - } - + } -}
Effect:
Probe into the source--system.environment of class library