Returns the value of the specified environment variable.
- variable
- A string containing the name of an environment variable.
A string containing the current setting of variable , or null.
Type Reason System.Security.Permissions.EnvironmentPermission Requires permission to read environment variables. See System.Security.Permissions.EnvironmentPermissionAccess.Read.
Type Reason ArgumentNullException variable is a null reference. System.Security.SecurityException The caller does not have the required permission.
If variable contains a valid name for an environment variable, and if the caller has sufficient permissions, this method returns the current setting for variable. Environment variable names are case-insensitive.
If variable specifies an invalid name or the system does not support environment variables, this method returns null .
Note: To obtain names and settings for all environment variables, use the Environment.GetEnvironmentVariables method.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0