title: Windows service running as system cannot access C:\users\
body: <p>I've got a Windows service installed as the local system account, and occasionally it builds a list of directories on the machine.  It fails on Windows 7 under the c:\users... directories.    I checked those folders out, and they appear to be under Full Control to the system account.  Why would I be unable to access these directories?</p>
  
  <pre><code>System.UnauthorizedAccessException: Access to the path 'C:\Users\Public\Documents\My         Videos' is denied.
  at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
  at System.IO.Directory.InternalGetFileDirectoryNames(String path, String userPathOriginal,   String searchPattern, Boolean includeFiles, Boolean includeDirs, SearchOption searchOption)
  at System.IO.Directory.GetDirectories(String path, String searchPattern, SearchOption searchOption)
  at LS.Core.Backup.DirectoryMapper.GetDirectories(String SeedDir, Int32 Count)
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>See my answer below for details, but I've also posted the class I used to work around this issue. See <a href="https://gist.github.com/tghamm/8392953" rel="nofollow">GitHub Gist - DirectoryHelper</a></p>