操作系统的驱动器信息包括。
Drive Name Volume Label Free Space Total Size Drive Format Drive Type
要获取有关驱动器的上述信息,请尝试运行以下代码-
using System.IO; using System; class Program { static void Main() { DriveInfo driveInfo = new DriveInfo("D"); Console.WriteLine(driveInfo.Name); Console.WriteLine(driveInfo.VolumeLabel); Console.WriteLine(driveInfo.AvailableFreeSpace); Console.WriteLine(driveInfo.TotalFreeSpace); Console.WriteLine(driveInfo.TotalSize); Console.WriteLine(driveInfo.DriveFormat); Console.WriteLine(driveInfo.DriveType); } }
输出结果
以下是输出-
D: NTFS 76767677788 76767677788 45463434799 NTFS Fixed
注–输出可能会因不同的操作系统而异。