首页 > Windows开发 > 详细

C#读取驱动器信息

时间:2016-08-19 15:05:31      阅读:235      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!