Sử dụng thuộc tính DriveFormat để lấy định dạng ổ đĩa trong C #.
Đặt ổ đĩa mà bạn muốn hiển thị định dạng -
DriveInfo dInfo = new DriveInfo("C"); Bây giờ, hãy sử dụng DriveFormat để lấy định dạng ổ đĩa -
dInfo.DriveFormat
Các định dạng ổ đĩa cho hệ thống windows có thể là NTFS hoặc FAT32.
Đây là mã hoàn chỉnh -
Ví dụ
using System;
using System.Linq;
using System.IO;
public class Demo {
public static void Main() {
DriveInfo dInfo = new DriveInfo("C");
Console.WriteLine("Drive Format = "+dInfo.DriveFormat);
}
} Đầu ra
Sau đây là kết quả -
Drive Format = NTFS