Mono Class Library: System.Environment Overview | Members

System.Environment.ExpandEnvironmentVariables Method

Expands all the environment variable references in the given string with the value of the environment variable.

public static string ExpandEnvironmentVariables (string name)

Parameters

name
The string containing 0 or more environment variable references (like %HOME%).

Returns

Documentation for this section has not yet been entered.

Remarks

In the given string parameter, the reference to the environment variable is written in Windows style, e.g.

%HOME%

Note that the expansion only takes place if the environment variable is set. If it's not set, the reference is printed as is.

C# Example

using System;

class SystemDemo
{
	public static void Main(string[] args)
	{
		Console.WriteLine(Environment.ExpandEnvironmentVariables("This app is running under the display %DISPLAY%"));
	}
}
  
prints

This app is running under the display :0.0

when running on the :0 display on Linux.

Requirements

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