Get the OS, Service Pack, and CLR Version info using C#

You can use the System.Environment.OSVersion class to access detail s of the user’s system environment

The below code demonstrates using the OSVersion object to access environmental info:

OperatingSystem osObj = System.Environment.OSVersion;
Console.WriteLine(“Platform is: {0}”, osObj.Platform);
Console.WriteLine(“Service Pack is: {0}”, osObj.ServicePack);
Console.WriteLine(“Version is: {0}”, osObj.Version);
Console.WriteLine(“VersionString is: {0}”, osObj.VersionString);
Console.WriteLine(“CLR Version is: {0}”, System.Environment.Version);

Note that the OSVersion object will not provide details such as “Windows Vista” or “Windows 7″ which are technically brand names and not systems versions, you should expect to be passed the corresponding system version numbers instead.

Twitter Digg Delicious Stumbleupon Technorati Facebook Email

No comments yet... Be the first to leave a reply!