CSharp examples for Operating System:Environment
Retrieve the Value of an Environment Variable
using System;/*ww w. j a v a 2 s . c o m*/ using System.Collections; class MainClass { public static void Main() { Console.WriteLine("Path = " + Environment.GetEnvironmentVariable("Path")); Console.WriteLine(Environment.NewLine); Console.WriteLine(Environment.ExpandEnvironmentVariables("The Path on %computername% is %Path%")); Console.WriteLine(Environment.NewLine); IDictionary vars = Environment.GetEnvironmentVariables( EnvironmentVariableTarget.Process); foreach (string s in vars.Keys) { if (s.ToUpper().StartsWith("U")) { Console.WriteLine(s + " = " + vars[s]); } } } }