Csharp/C#教程:如何在.NET Core中修改文件访问控制分享


如何在.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

(0)
上一篇 2021年12月24日
下一篇 2021年12月24日

精彩推荐