ManagementObject disk = new ManagementObject(
   "win32_logicaldisk.deviceid=\"c:\""); //把c:改为你要的驱动器
  disk.Get();
  Console.WriteLine("Logical Disk Type = " + disk["DriveType"]);
  Console.ReadLine(); Type:
1 No type 
2 Floppy disk 
3 Hard disk 
4 Removable drive or network drive 
5 CD-ROM 
6 RAM disk

解决方案 »

  1.   

    忘了说了,这里使用了WMI,需要
    using System.Management;关于WMI的相关,可以搜搜以前的文章,有过专题
      

  2.   

    WMI处理这些方面的太直观太容易了
      

  3.   

    我是这么做的:
    using System;
    using System.Drawing;
    using System.Collections;
    using System.ComponentModel;
    using System.Windows.Forms;
    using System.Data;
    using System.IO;
    using System.Runtime.InteropServices;//该函数用来获取驱动器的类型
    [DllImport("kernel32")]
    static extern uint GetDriveType(string name);
    /// </summary>
    private void ListDrives()
    {
    …………
    //获取系统中的所有逻辑盘
    string[] drives = Directory.GetLogicalDrives(); for( int i=0;i<drives.Length;i++)
    {
    …………
    //根据驱动器的不同类型来确定所进行的操作
    switch ( GetDriveType( drives[i]))
    {
    case 2: //软驱
    …………

    case 3: //硬盘
    …………

    case 5: //光驱
    …………

    }
    }
    }
      

  4.   

    这里有一些关于使用WMI取的系统信息的内容:
    http://www.uncj.net/news/show.aspx?id=77
      

  5.   

    study!,我还是喜欢用api函数GetDriveType()