I am looking for a way in c# to reset a file’s permissions to be inherited from the parent as if the file was created or copied to that directory.
I can’t seem to find anything on this from a file standpoint (I found a reference or two for directories, but I can’t get them to translate to a file for some reason). C# – Windows ACL – Applying Inherited Permissions, for example. But I am not sure what the value for LOGON_USER_NAME is supposed to be and as far as I can get is getting a System.ArgumentExcpetion of “no flags can be set”
I finally found the answer over here. File.Move does not inherit permissions from target directory?
Update
While the code snip above does add in the inherited permissions, it does not remove any existing explicit permissions. My final code looks more like this.
Update 2
Or, simply use TGasdf’s more concise 3 line solution that is elsewhere on this page…