Search Results

Wednesday, April 8, 2009

(2)An interesting Aside:Some Additional Members of the System.Enviroment Class

This class allows you to obtain a number of details regarding the operating system currently hosting your .Net Application using various static members.

//**************************************************************//
The program below is an Example Of Enviroment Class...
//**************************************************************//
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{

ShowEnviromentDetails();
//wait for enter key to be presses before quit
Console.ReadLine();

}
static void ShowEnviromentDetails()
{
//Print Out the drives on this machine and other interesting details

foreach (string drive in Environment.GetLogicalDrives())
Console.WriteLine("Drive:{0}", drive);

Console.WriteLine("OS:{0}", Environment.OSVersion);
Console.WriteLine("Number of processors:{0}",Environment.ProcessorCount);
Console.WriteLine(".Net Version:{0}",Environment.Version);

}
}
}
//**************************************************************//

//**************************************//
Select Properties of System.Enviroment
//**************************************//

**********************************
Property and its Meaning in Life
**********************************

Exit Code
Gets or sets the exit code any where within the application

Machine Name
Gets the name of the current machine

NewLine
Gets the new line symbol for the current enviroment

StackTrace
Gets the current stack trace information for the application

System Directory
Returns the full path to the system directory

User Name
Returns the name of user that started this application

//*********************************************************************************//

You can use more Enviroment variables by using the intellisence...just like this

Console.WriteLine(Environment.(Here a list of properties will appear in front of you) );

Do Check this for your practice...

No comments:

Post a Comment