How to detect Windows 8 Operating system using C# 4.0?
.net, c#, windows, winforms
Solution
Version win8version = new Version(6, 2, 9200, 0);
if (Environment.OSVersion.Platform == PlatformID.Win32NT &&
Environment.OSVersion.Version >= win8version)
{
// its win8 or higher.
}
Update for windows 8.1 and higher:
Okay guys, it seems to me that this piece of code has been marked as deprecated by Microsoft itself. I leave a link here so you could read more about it.
In short, it says:
For windows 8 and higher, there always will be the same version number of (6, 2, 9200, 0). And rather than looking for Windows version, go look for the actual feature which existance you are trying to resolve.
Problem
I have to detect Windows 8 Operating system in my C# Windows Application and do some settings. I know we can detect Windows 7 using `Environment.OSVersion`, but how can windows 8 be detected? Thanks in advance.