我在 C# 中的小程序中为 Windows上的目录文件夹“ wwwroot ”上的“ Everyone ”分配访问权限时遇到问题。这是我的做法。
//I also try with 'S-1-1-0'/'Everyone' but it's the same result
string userPermission = "Everyone" ;
DirectoryInfo myDirRoot = new DirectoryInfo(myArmsUpdate.InstallationPath);
DirectorySecurity myDirectorySecurity = myDirRoot.GetAccessControl();
FileSystemAccessRule myPermission = new FileSystemAccessRule(userPermission , FileSystemRights.ReadAndExecute, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
myDirectorySecurity.AddAccessRule(myPermission);
myDirRoot.SetAccessControl(myDirectorySecurity);
但是我仍然遇到同样的错误:
System.Security.Principal.IdentityNotMappedException