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?
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)
Update:
See my answer below for details, but I've also posted the class I used to work around this issue. See GitHub Gist - DirectoryHelper