title: C# determine OS is Windows 7 or WIndows Windows Server 2008
body: <p>I am using .NET framework 3.5 version, and the program has to detect all the Windows versions(including Windows XP, Windows Vista, Windows 7, Windows 8, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012).</p>
  
  <p>The problem is how can I determine the OS in below situations?</p>
  
  <ul>
  <li>Windows Vista and Windows Server 2008 Version number both are 6.0.</li>
  <li>Windows 7 and Windows Server 2008 R2 Version number both are 6.1.</li>
  <li>Windows 8 and Windows Server 2012 Version number both are 6.2.</li>
  </ul>
  
  <p>I have found the below code but I can't use because I'm using .NET Framework 3.5.</p>
  
  <pre><code>var name = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType&lt;ManagementObject&gt;()
                    select x.GetPropertyValue("Caption")).FirstOrDefault();
  return name != null ? name.ToString() : "Unknown";
  </code></pre>
  
  <p>How can I solve this problem?</p>