在 C# 中獲取驅動器格式
使用 DriveFormat 屬性在 C# 中獲取驅動器格式。
設定要顯示其格式的驅動器 -
DriveInfo dInfo = new DriveInfo("C");
現在,使用 DriveFormat 來獲取驅動器格式 -
dInfo.DriveFormat
Windows 系統的驅動器格式可以是 NTFS 或 FAT32。
以下是完整程式碼 -
示例
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); } }
輸出
以下是輸出 -
Drive Format = NTFS
廣告