【发布时间】:2017-05-25 21:26:01
【问题描述】:
我们将 .NET 4.0 类库移植到 .NET Core 1.1 时遇到了 .NET Core CLR 中对文件安全性和权限的支持非常有限的问题。
我们试图将访问控制权限设置为如下文件,并且 FileInfo 似乎不再具有任何 SetAccessControl 或 GetAccessControl。
// Get a FileSecurity object that represents the
// current security settings.
FileSecurity fSecurity = File.GetAccessControl(fileName);
// Add the FileSystemAccessRule to the security settings.
fSecurity.AddAccessRule(new FileSystemAccessRule(account,
rights, controlType));
// Set the new access settings.
File.SetAccessControl(fileName, fSecurity);
目标只是为文件的当前所有者添加执行权。
【问题讨论】: