zl程序教程

您现在的位置是:首页 >  其它

当前栏目

获取磁盘的文件系统类型

获取 类型 磁盘 文件系统
2023-09-14 09:00:20 时间

实现效果:

  

知识运用:

  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;  //获取文件类型
                }
            }
        }