0

有没有办法检查司机是否准备好?

因为我列出了所有目录,例如当它到达 DVD 时,我得到一个异常,说驱动程序没有准备好。

非常感谢

@{
try
{
    //Resgata todos os drivers Lógicos do Sistema
    string[] drives = System.IO.Directory.GetLogicalDrives();

    Response.Write("<ul class=\"jqueryFileTree\" style=\"display: none;\">\n");

    //Itera sobre cada driver no array
    foreach(string drive in directoryEntries) {


        //Para cada driver cria um LI A 
        Response.Write("\t<li class=\"directory collapsed\"><a href=\"#\" rel=\"" + drive + "\">" + drive + "</a></li>\n");

        //Resgata subDiretórios de cada driver
        string[] directoryEntries = System.IO.Directory.GetFileSystemEntries(drive); 
    }


}
catch (Exception)
{

    throw;
}
}

多谢

4

1 回答 1

1

查看 DriveInfo.IsReady 属性。

  DriveInfo[] allDrives = DriveInfo.GetDrives();

  foreach (DriveInfo d in allDrives)
  {
      if (d.IsReady == true)
      {
         // do something
      }
   }

可以在此 MSDN 条目上找到更多信息:

于 2012-11-27T03:26:56.003 回答