title: System.UnauthorizedAccessException when giving access to new folder
body: <p>I am using below code to grant access to IIS Folder:</p>
  
  <pre><code>string path=@"C:\inetpub\logs\LogFiles\W3SVC6\";
  AddDirectorySecurity(path, "everyone", FileSystemRights.ReadData, AccessControlType.Allow);
  
  public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
  {
      DirectoryInfo dInfo = new DirectoryInfo(FileName);
      DirectorySecurity dSecurity = dInfo.GetAccessControl();
  
      dSecurity.AddAccessRule(new FileSystemAccessRule(Account, Rights,
      ControlType));      
      dInfo.SetAccessControl(dSecurity);
  
  }
  </code></pre>