C# Environment GetEnvironmentVariable(String)
Description
Environment GetEnvironmentVariable(String)
retrieves
the value of an environment variable from the current process.
Syntax
Environment.GetEnvironmentVariable(String)
has the following syntax.
public static string GetEnvironmentVariable(
string variable
)
Parameters
Environment.GetEnvironmentVariable(String)
has the following parameters.
variable
- The name of the environment variable.
Returns
Environment.GetEnvironmentVariable(String)
method returns The value of the environment variable specified by variable, or null if the
environment variable is not found.
Example
The following example demonstrates the GetEnvironmentVariable method.
using System.IO;/*from w w w.j ava 2 s. c o m*/
using System;
public class MainClass{
public static void Main(String[] argv){
Environment.CurrentDirectory = Environment.GetEnvironmentVariable("windir");
DirectoryInfo info = new DirectoryInfo(".");
Console.WriteLine("Directory Info: "+info.FullName);
}
}
The code above generates the following result.