查看当前netfamework版本
private static string GetDotNetVersion(){string text = "0";using (RegistryKey registryKey = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, "").OpenSubKey("SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\")){string[] subKeyNames = registryKey.GetSubKeyNames();foreach (string text2 in subKeyNames){if (text2.StartsWith("v")){RegistryKey registryKey2 = registryKey.OpenSubKey(text2);string text3 = (string)registryKey2.GetValue("Version", "");if (string.Compare(text3, text) > 0){text = text3;}if (!(text3 != "")){string[] subKeyNames2 = registryKey2.GetSubKeyNames();foreach (string name in subKeyNames2){RegistryKey registryKey3 = registryKey2.OpenSubKey(name);text3 = (string)registryKey3.GetValue("Version", "");if (string.Compare(text3, text) > 0){text = text3;}}}}}}return text;}
评论