ข้อมูลไดรฟ์ของระบบปฏิบัติการประกอบด้วย
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
หมายเหตุ − ผลลัพธ์อาจแตกต่างกันไปตามระบบปฏิบัติการที่แตกต่างกัน