获取各种路径

//应用程序的当前工作目录。 
System.IO.Directory.GetCurrentDirectory(); 

//获取程序的基目录。
System.AppDomain.CurrentDomain.BaseDirectory; 

//获取和设置包括该应用程序的目录的名称。
System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase; 

//获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称。 
System.Windows.Forms.Application.StartupPath; 

//获取启动了应用程序的可执行文件的路径及文件名 
System.Windows.Forms.Application.ExecutablePath; 

//获取Windows系统所在路径
Environment.GetEnvironmentVariable("SystemRoot");
//或者
Environment.GetEnvironmentVariable("windir");

 

 

获取操作系统版本号

//获取主版本
System.Environment.OSVersion.Version.Major

//获取副版本
System.Environment.OSVersion.Version.Minor

 

+-----------------------------------------‍------------------------------------------------------------------------------------------+ 
|                  | Windows | Windows | Windows | Windows NT | Windows | Windows | Windows | Windows |

+-----------------------------------------‍------------------------------------------------------------------------------------------+ 
|                  |       95     |     98        |      Me     |       4.0          |     2000    |      XP      |     Vista    |      7      |
+-----------------------------------------------------------------------------------------------------------------------------------+ 
| PlatformID |      1         |      1       |        1      |          2       |       2        |      2       |                |                |
+-----------------------------------------------------------------------------------------------------------------------------------+ 
| 主版本号   |      4          |       4       |         4       |         4        |      5        |      5       |       6       |        6      |
+-----------------------------------------------------------------------------------------------------------------------------------+ 
| 副版本号 |       0         |       10      |       90      |        0        |      0         |      1       |        0       |        1      |
+-----------------------------------------------------------------------------------------------------------------------------------+

 

相关文章:

  • 2022-03-10
  • 2021-05-29
  • 2021-05-31
  • 2022-02-14
  • 2022-12-23
  • 2021-09-18
猜你喜欢
  • 2021-10-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-20
  • 2021-10-26
  • 2021-11-28
相关资源
相似解决方案