如何在.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
实例。
- 在没有Microsoft.Office.Interop的情况下,将.NET doc和docx格式转换为.NET Core中的PDF
- NuGet.Config文件位于Visual Studio 2017项目中的哪个位置?
- 从csproj引用xproj
- 如何从.net核心中的appsettings.json中提取列表
- 使用特定的HttpMessageHandler注入单实例HttpClient
- .NET Core 2.1 – 循环中的正则表达式200x比2.0慢(简单基准中为3x)
- 缓存在Identity Server 4中似乎不起作用
- 将私钥/公钥从X509证书导出到PEM
- 如何让.NET Core项目复制NuGet引用来构建输出?