在c#中如何查看硬盘分区的文件系统类型

如何使用代码查看分区的格式

using System;
using System.IO;

namespace onitroad
{
    class IsNTFS
    {
        public static int Main(string[] args)
        {
            try
            {

                DriveInfo[] allDrives = DriveInfo.GetDrives();

                foreach (DriveInfo drv in allDrives)
                {
                    if (drv.IsReady)
                    {
                        Console.WriteLine(drv.DriveFormat.ToUpper());
                        if (drv.DriveFormat == "NTFS")
                        {
                            return 0;
                        }
                        else
                        {
                            return 2;
                        }
                    }
                    else
                    {
                        Console.WriteLine(drv.DriveType.ToString().ToUpper());
                        return 1;
                    }
                }

            }
            catch (Exception e)
            {

                return -1;
            }
            return -1;
        }

    }
}
日期:2020-04-11 22:50:22 来源:oir作者:oir