zoukankan      html  css  js  c++  java
  • C#获取程序和操作系统路径,操作系统版本

    获取各种路径

    //应用程序的当前工作目录。 
    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      |
    +-----------------------------------------------------------------------------------------------------------------------------------+

  • 相关阅读:
    JS-只能输入中文和英文
    强密码正则表达式
    java 实体序列化的意义
    数据库中存在0,1,2.....或者1,null,2 排序时让0或者null在最后的sql语句
    Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile 解决办法
    C#中的线程(二) 线程同步基础
    C#中的线程(一)入门
    C#多线程编程
    C#(asp.net )读取ASHX文件(一般处理程序)
    Oracle中三种循环(For、While、Loop)
  • 原文地址:https://www.cnblogs.com/xpvincent/p/2844294.html
Copyright © 2011-2022 走看看