title: Getting 'The device is not ready' error when using DriveInfo.GetDrives()
body: <p>i am trying to make a program that looks at all the drives, tries to find a removable one with the name "DOM WORK" and then gets the drive name (like E:) and then prints that. Unfortunately i get this error message:</p>
  
  <pre><code>Unhandled Exception: System.IO.IOException: The device is not ready.
  
     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
     at System.IO.__Error.WinIODriveError(String driveName, Int32 errorCode)
     at System.IO.DriveInfo.get_VolumeLabel()
     at WorkSync.Program.Main(String[] args) in d:\dominic\documents\visual studio 2015\Projects\WorkSync\WorkSync\Program.cs:line 19
  </code></pre>
  
  <p>I have tried building the program as an executable and then running it with administrator privileges, which did not work.</p>
  
  <p>Here is my code that i am using:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  
  namespace WorkSync
  {
      class Program
      {
          static void Main(string[] args)
          {
              DriveInfo[] allDrives = DriveInfo.GetDrives();
              string memStickName = "";
  
              foreach(DriveInfo drive in allDrives)
              {
                  Console.WriteLine(drive.VolumeLabel);
                  if (drive.VolumeLabel == "DOM WORK" &amp;&amp; drive.DriveType.ToString() == "removable")
                  {
                      memStickName = drive.Name;
                      break;
                  }
              }
  
              Console.WriteLine(memStickName);
          }
      }
  }
  </code></pre>