title: Determine if Removable Drive is Read-Only
body: <p>I am working on determining if a removable drive is read-only using C# (.NET 4.0).  I've read many articles that detail the process for determining if a directory is read-only using the following code that came from <a href="https://stackoverflow.com/questions/7511592/check-if-folder-is-read-only-in-c-net">this page</a>:</p>
  
  <pre><code>var di = new DirectoryInfo(folderName);
  
  if(di.Exists)
  {
      if (di.Attributes.HasFlag(FileAttributes.ReadOnly))
      {
          //IsReadOnly...
      }
  }
  </code></pre>
  
  <p>However, I've tried this method using the root directory, and even though the entire drive is read-only (I'm using an SD Card that is locked), I never make it to the line <code>//IsReadOnly...</code>.  The contents of the drive cannot be guaranteed (it could be empty or have many, many files), so testing any sub-directory is out of the question.  I know an easy test would be to write a small file to the drive and catch any exceptions, but I would prefer a different method.</p>
  
  <p>Does anyone know of a good solution to this problem?</p>