title: "Access to the system path is denied" when using 'System.IO.Directory.Delete'
body: <p>I'm using <code>System.IO.Directory.Delete</code> and trying to delete system folders such as 'My Music', 'My Videos' etc, but I get errors similar to "Access to the system path 'C:\users\jbloggs\Saved Games' is denied". I can however delete these folders via Explorer without any problems, I have full permissions to these folders. Any suggestions on what I can try?</p>
  
  <p>My code:</p>
  
  <pre><code>public static void ClearAttributes(string currentDir)
  {
      if (Directory.Exists(currentDir))
      {
          string[] subDirs = Directory.GetDirectories(currentDir);
          foreach (string dir in subDirs)
              ClearAttributes(dir);
          string[] files = files = Directory.GetFiles(currentDir);
          foreach (string file in files)
              File.SetAttributes(file, FileAttributes.Normal);
      }
  }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>try
  {
      ClearAttributes(FolderPath);
      System.IO.Directory.Delete("C:\\users\\jbloggs\\Saved Games", true);
  }
  catch (IOException ex)
  {
      MessageBox.Show(ex.Message);
  }
  </code></pre>