I have the following code in C#:
if (!Directory.Exists(inputFolder))
{
return true;
}
else
{
var me = new DirectoryInfo(inputFolder);
AuthorizationRuleCollection rules = null;
WindowsIdentity identity = null;
try
{
rules = me.GetAccessControl().GetAccessRules(true, true, typeof(SecurityIdentifier));
identity = WindowsIdentity.GetCurrent();
}
catch (UnauthorizedAccessException uae)
{
return false;
}
string userSID = identity.User.Value;
foreach (FileSystemAccessRule rule in rules)
{
if ((rule.FileSystemRights.HasFlag(FileSystemRights.Read) ||
rule.FileSystemRights.HasFlag(FileSystemRights.ReadAttributes) ||
rule.FileSystemRights.HasFlag(FileSystemRights.ReadData) ||
rule.FileSystemRights.HasFlag(FileSystemRights.ReadAndExecute)) && rule.AccessControlType == AccessControlType.Deny)
{
return false;
}
}
return true;
}
And it works correctly in Windows, however, when I try to run this on mac OS X (Visual Studio for Mac) it throws an exception when trying to get the information from the method "GetAccessRules" or even the "GetAccessControl" saying:
"Access Control List (ACL) APIs are part of resource management on Windows and are not supported on this platform."
So here is my question:
Is there an alternative to do this in .net core? Or how should i manage these kind of permissions in .net core but in mac OS X?