How can I detect the Windows OS versions in .NET?
What code can I use?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
System.Environment.OSVersionhas the information you need for distinguishing most Windows OS major releases, but not all. It consists of three components which map to the following Windows versions:For a library that allows you to get a more complete view of the exact release of Windows that the current execution environment is running in, check out this library.
Important note: if your executable assembly manifest doesn’t explicitly state that your exe assembly is compatible with Windows 8.1 and Windows 10.0,
System.Environment.OSVersionwill return Windows 8 version, which is 6.2, instead of 6.3 and 10.0! Source: here.Update: In .NET 5.0 and later,
System.Environment.OSVersionalways returns the actual OS version. For more information, see Environment.OSVersion returns the correct operating system version.