Get the drive format in C#

CsharpProgrammingServer Side Programming

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
raja
Published on 05-Sep-2018 10:51:13
Advertisements