Environment.GetVariableValue C# (CSharp) Method

GetVariableValue() public method

public GetVariableValue ( string aKey ) : string
aKey string
return string
    public string GetVariableValue(string aKey)
    {
        StringBuilder builder = new StringBuilder(MAX_ENV_VALUE_LENGTH);
        int aSize = MAX_ENV_VALUE_LENGTH;
        int charsRead = 0;

        // Try to get the value.
        charsRead = Kernel32.GetEnvironmentVariable(aKey, builder, aSize);

        // Throw argument out of range exception if it does not exist
        if (0 == charsRead)
            throw new ArgumentOutOfRangeException(aKey);

        return builder.ToString();
    }