namespace ConsoleApp_DriveInfo
{
internal class Program
{
static void Main(string[] args)
{
Driveinfo();
}
static void Driveinfo()
{
DriveInfo driveInfo = new DriveInfo("d:/");
// [ 属性 ]
Console.WriteLine(driveInfo.DriveType); // 获取磁盘类型
Console.WriteLine(driveInfo.Name); // 磁盘盘符
Console.WriteLine(driveInfo.VolumeLabel); // 磁盘名称
Console.WriteLine(((driveInfo.TotalSize/1024)/1024)/1024+"GB"); // 获取磁盘总容量
Console.WriteLine(((driveInfo.TotalFreeSpace/1024)/1024)/1024+"GB"); // 获取磁盘可用空间
Console.WriteLine(driveInfo.DriveFormat); // 磁盘格式
foreach (var x in DriveInfo.GetDrives()) { Console.WriteLine(x); } // 获取所有盘符
}
}
}
标签:1024,Console,C#,获取,driveInfo,WriteLine,磁盘,DriveInfo From: https://www.cnblogs.com/xs-xs/p/18092059