با استفاده از کلاس هایی که در namespace System.IO وجود دارد، می توانید این کار را انجام دهید:
try
{
//Get all the drives of system
DriveInfo[] drives = DriveInfo.GetDrives();
int count=0;
foreach (DriveInfo info in drives)
{
if (info.IsReady)
{
count += 1;
Console.WriteLine("*************Drive {0}*************", count);
Console.WriteLine("Drive Name:{0}", info.Name);
Console.WriteLine("Drive Size:{0} bytes", info.TotalSize.ToString());
Console.WriteLine("Free Space:{0} bytes", info.TotalFreeSpace.ToString());
Console.WriteLine("Drive Format:{0}", info.DriveFormat);
Console.WriteLine("Drive Type:{0}", info.DriveType);
Console.WriteLine("Drive Volume Label:{0}", info.VolumeLabel);
}
}
Console.ReadKey();
}
catch (Exception ex)
{
}