How to Get Operating System Information in C#

Waqas Anwar
11 December 2010
9310 Views

If you want to get Operating System information using C#, you can use System.Environment.OSVersion property as shown below:

Console.WriteLine(System.Environment.OSVersion.Platform);
Console.WriteLine(System.Environment.OSVersion.ServicePack);
Console.WriteLine(System.Environment.OSVersion.Version);
Console.WriteLine(System.Environment.OSVersion.VersionString);

The output will be similar to the following depending on your operating system

Win32NT
Service Pack 3
5.1.2600.196608
Microsoft Windows NT 5.1.2600 Service Pack 3