Mono Class Library: System.Environment Overview | Members

System.Environment.GetEnvironmentVariable Method

Returns the value of the specified environment variable.

public static string GetEnvironmentVariable (string variable)

Parameters

variable
A string containing the name of an environment variable.

Returns

A string containing the current setting of variable , or null.

Permissions

TypeReason
System.Security.Permissions.EnvironmentPermissionRequires permission to read environment variables. See System.Security.Permissions.EnvironmentPermissionAccess.Read.

Exceptions

TypeReason
ArgumentNullExceptionvariable is a null reference.
System.Security.SecurityExceptionThe caller does not have the required permission.

Remarks

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.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0