如何在.NET Core中修改文件访问控制
我正在尝试更改.NET Core中文件的权限。 但是,似乎FileInfo不再具有任何SetAccessControl
。
// 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);
目标只是将执行权添加到文件的当前所有者(不是Windows或Unix特定function)。
有关如何在.NET Core上执行此操作的任何线索?
FileSecurity
类现在是.NET Core的System.IO.FileSystem.AccessControl包的一部分。 不再有File.GetAccessControl
方法,因此您需要自己实例化FileSecurity
实例。
上述就是C#学习教程:如何在.NET Core中修改文件访问控制分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/990406.html