zoukankan      html  css  js  c++  java
  • LocalDriveInfo

     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.IO;
     5 
     6 namespace LocalDriveInfo
     7 {
     8     class Program
     9     {
    10         static void Main(string[] args)
    11         {
    12             string[] drives = System.Environment.GetLogicalDrives();
    13             DriveInfo driveInfo = null;
    14             System.Console.WriteLine(GetOperationSystemInName());
    15             System.Console.WriteLine("卷标 盘符 类型 文件系统 总大小(byte) 可用空间大小(byte)");
    16             for (int i = 0; i < drives.Length; i++)
    17             {
    18                 driveInfo = new DriveInfo(drives[i]);
    19                 if (driveInfo.IsReady)
    20                 {
    21                     System.Console.WriteLine("{0} {1} {2} {3} {4} {5}", driveInfo.VolumeLabel, driveInfo.Name,
    22                         driveInfo.DriveType, driveInfo.DriveFormat, driveInfo.TotalSize.ToString("###,###"/**//*/ (1024 * 1024)*/, driveInfo.AvailableFreeSpace.ToString("###,###"/**//*/ (1024*1024))*/);
    23                 }
    24                 else
    25                 {
    26                     System.Console.WriteLine("{0} {1} {2} {3} {4} {5}""", driveInfo.Name,
    27                         driveInfo.DriveType, """""""");
    28                 }
    29             }
    30             System.Console.ReadLine();
    31         }
    32 
    33         /**////<summary>
    34         /// 获取系统名称
    35         /// </summary>
    36         /// <returns></returns>
    37         public static string GetOperationSystemInName()
    38         {
    39             OperatingSystem os = System.Environment.OSVersion;
    40             string osName = "UNKNOWN";
    41             switch (os.Platform)
    42            {
    43                 case PlatformID.Win32Windows:
    44                     switch (os.Version.Minor)
    45                    {
    46                         case 0: osName = "Windows 95"break;
    47                         case 10: osName = "Windows 98"break;
    48                         case 90: osName = "Windows ME"break;
    49                     }
    50                     break;
    51                 case PlatformID.Win32NT:
    52                     switch (os.Version.Major)
    53                     {
    54                         case 3: osName = "Windws NT 3.51"break;
    55                         case 4: osName = "Windows NT 4"break;
    56                         case 5if (os.Version.Minor == 0)
    57                             {
    58                                 osName = "Windows 2000";
    59                             }
    60                             else if (os.Version.Minor == 1)
    61                             {
    62                                 osName = "Windows XP";
    63                             }
    64                             else if (os.Version.Minor == 2)
    65                             {
    66                                 osName = "Windows Server 2003";
    67                             }
    68                             break;
    69                         case 6: osName = "Longhorn"break;
    70                     }
    71                     break;
    72             }
    73             return String.Format("{0},{1}", osName, os.Version.ToString());
    74         }
    75     }
    76 }
  • 相关阅读:
    .NetCore 3.1和.NetCore 5.0 中WebApi的请求参数的验证方法
    php 使脚本持续的运行
    Elasticsearch es三种分页方式和对比
    es 大批量写入提高性能的策略
    php 使用多进程批量插入数据
    【转】EM算法MATLAB代码及详细注解
    【转】详解EM算法与混合高斯模型(Gaussian mixture model, GMM)
    【转】高斯混合模型
    【转】二维高斯分布(Two-dimensional Gaussian distribution)的参数分析
    word使用dot模板以spring word 模板为例
  • 原文地址:https://www.cnblogs.com/tonybinlj/p/1328819.html
Copyright © 2011-2022 走看看