Get the drive format in C#


Use the DriveFormat property to get the drive format in C#.

Set the drive for which you want to display the format −

DriveInfo dInfo = new DriveInfo("C");

Now, use DriveFormat to get the drive format −

dInfo.DriveFormat

The drive formats for a windows system can be NTFS or FAT32.

Here is the complete code −

Example

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);
   }
}

Output

The following is the output −

Drive Format = NTFS

Updated on: 06-Apr-2020

185 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements