DriveInfo類的基本操作
阿新 • • 發佈:2019-01-01
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace DriveInfoDemo { class Program { static void Main(string[] args) { DriveInfo[] allDrives = DriveInfo.GetDrives(); foreach (DriveInfo d in allDrives) { Console.WriteLine("驅動器:{0}",d.Name); Console.WriteLine("型別:{0}",d.DriveType); if (d.IsReady) { Console.WriteLine("卷標:{0}", d.VolumeLabel); Console.WriteLine("檔案系統:{0}", d.DriveFormat); Console.WriteLine("當前可用空間:{0}", d.AvailableFreeSpace); Console.WriteLine("可用空間:{0}",d.TotalFreeSpace); Console.WriteLine("磁碟總大小:{0}",d.TotalSize); } } Console.ReadLine(); } } }