获取磁盘的文件系统类型

实现效果:

  

知识运用:

  DriveInfo类的GetDrives方法   Name属性   IsReady属性  DriveFormat属性

  public bool IsReady {get;}        //驱动器是否已准备好

  public string DriveFormat {get;}    //获取文件系统的类型

实现代码:

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DriveInfo[] drive = DriveInfo.GetDrives();
            foreach( DriveInfo d in drive )
            {
                if (comboBox1.SelectedItem.ToString() == d.Name)
                {
                    if (d.IsReady)                      //如果准备好
                        textBox1.Text = d.DriveFormat;  //获取文件类型
                }
            }
        }

  

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10295606.html