Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

รับรูปแบบไดรฟ์ใน 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