C# Frequently Asked Questions

The C# team posts answers to common questions

How do I get and set Environment variables?

Use the System.Environment class.
Specifically the GetEnvironmentVariable and SetEnvironmentVariable methods.

Admitedly, this is not a question specific to C#, but it is one I have seen enough C# programmers ask, and the ability to set environment variables is new to the Whidbey release, as is the EnvironmentVariableTarget enumeration which lets you separately specify process, machine, and user.

Brad Abrams blogged on this way back at the start of this year, and followed up with a solution for pre-Whidbey users.

[Author: SantoshZ]

Published Thursday, December 02, 2004 9:01 AM by CSharpFAQ
Filed under: , ,

Comments

 

Sheeshers said:

Can someone answer the question posted at the URL above?
December 3, 2004 7:49 AM
 

Ernst Kuschke (C# MVP) said:

Something I've wondered about a couple of times: When do environment variables get loaded? Does the OS periodically check for changes? Does it load them per session? No? Yes?
December 12, 2004 11:22 PM
 

FAQ C# said:

April 12, 2005 10:01 AM
 

FAQ C# said:

April 12, 2005 10:01 AM
 

FAQ C# (par Yannick Lejeune) said:

August 23, 2005 4:48 AM
 

FAQ C# (par Yannick Lejeune) said:

August 23, 2005 5:33 AM
 

Martin’s Blog » Blog Archive » log4net and the LocalApplicationData folder said:

December 11, 2007 3:22 PM
Anonymous comments are disabled

© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker