码迷,mamicode.com
首页 > Windows程序 > 详细

C#读取驱动器信息

时间:2016-08-19 15:07:30      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:

 1 using System;
 2 using System.IO;
 3 
 4 namespace _24._6_读取驱动器信息
 5 {
 6     class Program
 7     {
 8         static void Main(string[] args)
 9         {
10             var di = DriveInfo.GetDrives();
11 
12             foreach (var d in di)
13             {
14                 try
15                 {
16                     Console.WriteLine(d.Name);
17                     Console.WriteLine($"可用空间:{d.AvailableFreeSpace}");
18                     Console.WriteLine($"格式:{d.DriveFormat}");
19                     Console.WriteLine($"类型:{d.DriveType}");
20                     Console.WriteLine($"已准备好:{d.IsReady}");
21                     Console.WriteLine($"名称:{d.Name}");
22                     Console.WriteLine($"根目录:{d.RootDirectory}");
23                     Console.WriteLine($"总剩余空间:{d.TotalFreeSpace}");
24                     Console.WriteLine($"总空间:{d.TotalSize}");
25                     Console.WriteLine($"标签:{d.VolumeLabel}");
26                     Console.WriteLine();
27                 }
28                 catch (Exception ex)
29                 {
30                     Console.WriteLine(ex.Message);
31                 }
32             }
33         }
34     }
35 }

 

C#读取驱动器信息

标签:

原文地址:http://www.cnblogs.com/aka-code/p/5787435.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!