I have a Windows service installed as a local system account, and sometimes it creates a list of directories on the machine. It does not work on Windows 7 in the c: \ users directory .... I checked these folders and they seem to be under full control of the system account. Why can't I 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 more details, but I also posted a class that I used to solve this problem. See GitHub Gist - DirectoryHelper
source share