How to

get environment variables

Published: 5. January 2009 | Updated: 5. January 2009
License: Microsoft Public License (MS-PL)
Categories: Framework, Windows
Tags: C# Windows
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.Collections;

Iterate environment variables

foreach (DictionaryEntry entry in Environment.GetEnvironmentVariables())
{
    Console.WriteLine("{0} = {1}", entry.Key, entry.Value);
}

Get specific variable

string value = Environment.GetEnvironmentVariable("TEMP");
Send us feedback about this snippet »



Related Snippets: