1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | <br> /// <summary> /// 检测是否安裝4.7.2以上版本 /// </summary> /// <returns></returns> bool CheckNet472() { //C:\Windows\Microsoft.NET\Framework string net = "Microsoft.NET" ; string mscorlibFile = "mscorlib.dll" ; string RuntimeDirectory = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(); int index = RuntimeDirectory.IndexOf(net); if (index == -1) { MessageBox.Show(RuntimeDirectory, "錯誤,找不到系统路径" ); return false ; } string NetDirectory = RuntimeDirectory.Substring(0, index + net.Length); string Framework = Path.Combine(Path.Combine(NetDirectory, Path.Combine( "Framework" , "v4.0.30319" )), mscorlibFile); string Framework64 = Path.Combine(Path.Combine(NetDirectory, Path.Combine( "Framework64" , "v4.0.30319" )), mscorlibFile); int Nub = 0; if (File.Exists(Framework)) { Nub = GetFileVersion(Framework); } else if (File.Exists(Framework64)) { Nub = GetFileVersion(Framework64); } if (Nub > 471) { return true ; } else { return false ; } } int GetFileVersion( string FilePath) { FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(FilePath); string Version = fileVersionInfo.ProductVersion; string res = new string (Version.Where( char .IsDigit).ToArray()); if (res.Length > 1) { int NubCode = Convert.ToInt32(res.Substring(0, 3)); return NubCode; } return 0; } |
posted @ 2023-08-11 17:29
e度空间
阅读(90)
评论(0)
推荐(0)