title: How to grant full permission to a file created by my application for ALL users?
body: <p>The tool I develop needs to grant access rights &quot;Full Control&quot; to a file created by it. It needs to be read, modified and deleted from all windows accounts and even possible future accounts. Could this be achieved?</p>
  <p>I know I can try this for a SPECIFIC_USER:</p>
  <pre><code>FileSystemAccessRule rule = new FileSystemAccessRule(SPECIFIC_USER, FileSystemRights.FullControl, AccessControlType.Allow);
  FileSecurity fSecurity = File.GetAccessControl(filePath);
  fSecurity.SetAccessRule(rule);
  File.SetAccessControl(filePath, fSecurity);
  </code></pre>
  <p>But how do I grant it to all users? And even possible future accounts? If the latter part is not possible, how to go about the first requirement?</p>
  <p>Thanks.</p>
  <p>EDIT:</p>
  <p>This is the code which worked for me. Taken from the answerer's link.</p>
  <pre><code>private void GrantAccess(string fullPath)
  {
      DirectoryInfo dInfo = new DirectoryInfo(fullPath);
      DirectorySecurity dSecurity = dInfo.GetAccessControl();
      dSecurity.AddAccessRule(new FileSystemAccessRule(
          new SecurityIdentifier(WellKnownSidType.WorldSid, null), 
          FileSystemRights.FullControl,
          InheritanceFlags.ObjectInherit |
             InheritanceFlags.ContainerInherit,
          PropagationFlags.NoPropagateInherit,
          AccessControlType.Allow));
  
      dInfo.SetAccessControl(dSecurity);
  }
  </code></pre>
  <p>Note the <code>PropagationFlags.NoPropagateInherit</code> which is required (mentioned towards the last in the link). It does grant privilege to even future accounts.</p>