We were porting a .NET 4.0 class Library to .NET Core 1.1 and struck with an issue of very limit support for file Security and permissions in .NET Core CLR.
We were tryin
In dotnet standard/core:
Import the NuGet package as user bvpb mentioned. System.IO.FileSystem.AccessControl
Then instead of this (which only works in .NET Framework):
FileSecurity fSecurity = File.GetAccessControl(fileName);
use this (which works in all versions of .NET):
FileSecurity fSecurity = new FileSecurity(fileName, AccessControlSections.Owner |
AccessControlSections.Group |
AccessControlSections.Access);
You may need AccessControllSections.All
instead which requires the account running this code to have more permissions.