Finding more about Asp.Net Environment using the GetEnvironmentVariables method of Environment class

Hi,

What do you do when you need to find the values of various environment variables in the system like USERDOMAIN, PROCESSOR_ARCHITECTURE, COMPUTERNAME, USERNAME, PROCESSOR_IDENTIFIER, etc. well with asp.net this can be a very simple Job. You can get all these value along with a set of other values with the help of

Environment.GetEnvironmentVariables().

The static function returs the IDictionary collection of the Envirement varibales. To view the value you need to know the key for each value. But its not always known to us.

So what you can do is bind the dictionary to a grid view and see all the keys and values avilable.

You will not be able to bind the collection directly to a gridview with AutoGenerateColumns property true (which is the default value). To bind a type IDictionary to a gridview, we need to set the AutoGenerateColumns to false and add 2 bound columns with datafield key and value. This will display the list of all the envirement variables along with their value.

Vikram


Share this post   Email it |  digg it! |  reddit! |  bookmark it!

Feedback

Please post your comments:

Name:  
Email (optional): Your email address will not be posted.
URL (optional):
Comments: HTML will be ignored, URLs will be converted to hyperlinks  
Enter the text you see in the box:
 
Copyright © 2006 - 2009 Vikram Lakhotia