C# Environment SetEnvironmentVariable(String, String)
Description
Environment SetEnvironmentVariable(String, String)
creates,
modifies, or deletes an environment variable stored in the current process.
Syntax
Environment.SetEnvironmentVariable(String, String)
has the following syntax.
public static void SetEnvironmentVariable(
string variable,
string value
)
Parameters
Environment.SetEnvironmentVariable(String, String)
has the following parameters.
variable
- The name of an environment variable.value
- A value to assign to variable.
Returns
Environment.SetEnvironmentVariable(String, String)
method returns
Example
The following example tests whether an environment variable named APPDOMAIN exists in the current process.
using System;//w w w . ja va 2 s .co m
public class Example
{
public static void Main()
{
String envName = "AppDomain";
String envValue = "True";
if (Environment.GetEnvironmentVariable(envName) == null)
Environment.SetEnvironmentVariable(envName, envValue);
}
}
The code above generates the following result.