【发布时间】:2014-07-14 12:12:18
【问题描述】:
我在检测用户正在运行的操作系统时遇到了问题。我可以检测到它是否是版本 6,但我无法检测到是 6.1 还是 6.2 到目前为止,这是我的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OSDetect
{
class Program
{
static void Main(string[] args)
{
string osVer = System.Environment.OSVersion.Version.ToString();
if (osVer.StartsWith("6.1"))
{
Console.WriteLine("This program isn't compatible with Windows 7 and older.");
Console.ReadKey();
}
else
{
}
if (osVer.StartsWith("6.2"))
{
Console.Write("> ");
Console.ReadKey();
}
else
{
}
}
}
}
但这不起作用。
所以基本上我也希望它检测到次要版本。我该怎么做?
【问题讨论】:
-
System.Environment.OSVersion.Version.Minor
-
但它只检测到像 1 或 3 这样的值,它仍然没有检测到它是否是 Windows 6