C# -- 使用 DriveInfo 获取磁盘驱动器信息
2021-06-19 07:05
标签:key mat code roo info pre directory lin class C# -- 使用 DriveInfo 获取磁盘驱动器信息 1. 代码实现 2. 运行结果: C# -- 使用 DriveInfo 获取磁盘驱动器信息 标签:key mat code roo info pre directory lin class 原文地址:https://www.cnblogs.com/ChengWenHao/p/CSharpDriveInfo.html class Program
{
static void Main(string[] args)
{
GetComputerDisk();
Console.ReadKey();
}
private static void GetComputerDisk()
{
DriveInfo[] LocalDrive = DriveInfo.GetDrives();
for (int i = 0; i )
{
Console.WriteLine("------------------------------------------");
Console.WriteLine(string.Format("驱动器名称:{0}", LocalDrive[i].Name));
Console.WriteLine(string.Format("存储空间大小:{0}字节", LocalDrive[i].TotalSize));
Console.WriteLine(string.Format("可用空间大小:{0}字节", LocalDrive[i].AvailableFreeSpace));
Console.WriteLine(string.Format("可用空闲空间:{0}字节", LocalDrive[i].TotalFreeSpace));
Console.WriteLine(string.Format("文件系统:{0}", LocalDrive[i].DriveFormat));
Console.WriteLine(string.Format("驱动器类型:{0}", LocalDrive[i].DriveType));
Console.WriteLine(string.Format("驱动器IsReady:{0}", LocalDrive[i].IsReady));
Console.WriteLine(string.Format("驱动器的根目录:{0}", LocalDrive[i].RootDirectory));
Console.WriteLine(string.Format("驱动器卷标:{0}", LocalDrive[i].VolumeLabel));
}
}
}
上一篇:win文件时间问题
文章标题:C# -- 使用 DriveInfo 获取磁盘驱动器信息
文章链接:http://soscw.com/index.php/essay/95846.html