Get the value of an environment variable from the current process in CSharp

Description

The following code shows how to get the value of an environment variable from the current process.

Example


//  www . j a  va 2s. co m
using System.IO;
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.





















Home »
  C# Tutorial »
    Development »




Console
Encoding
Environment
Random