I'm trying to change the permissions of a file in .NET Core.
However, it seems that FileInfo doesn't have any SetAccessControl
anymore.
// Create a new FileInfo object.
FileInfo fInfo = new FileInfo(FileName);
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity fSecurity = fInfo.GetAccessControl();
// Add the FileSystemAccessRule to the security settings.
fSecurity.AddAccessRule(new FileSystemAccessRule(Account,
Rights,
ControlType));
// Set the new access settings.
fInfo.SetAccessControl(fSecurity);
The goal is just to add execution right to the current owner of a file (which is not Windows or Unix specific feature).
Any clues on how to do that on .NET Core ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…