0

値 '-536805376' は、このタイプの FileSystemRights の使用には無効です。パラメータ名: fileSystemRights

System.ArgumentOutOfRangeException: The value '-536805376' is not valid for this usage of the type FileSystemRights.
Parameter name: fileSystemRights
   at System.Security.AccessControl.FileSystemAccessRule.AccessMaskFromRights(FileSystemRights fileSystemRights, AccessControlType controlType)
   at System.Security.AccessControl.FileSystemSecurity.RemoveAccessRule(FileSystemAccessRule rule)
   at Program.ClearAccessRules(FileSystemSecurity fx)
   at Program.FixPermissions(String startingpoint)
   at Program.Main(String[] args)

障害のあるコードは次のブロックです。

        private static void ClearAccessRules(System.Security.AccessControl.FileSystemSecurity fx)
        {
            var rx = new List<System.Security.AccessControl.FileSystemAccessRule>();
            foreach (System.Security.AccessControl.FileSystemAccessRule k in fx.GetAccessRules(true, true, typeof(System.Security.Principal.SecurityIdentifier)))
                rx.Add(k);
            foreach (System.Security.AccessControl.FileSystemAccessRule k in rx)
                fx.RemoveAccessRule(k);
        }

私のコードにバグがある可能性はありますか、またはWindows 11GetAccessRules()で渡すことができないアクセス ルールを返し始めましたか?RemoveAccessRule()

私はエラー値をデコードしましたGENERIC_WRITE | GENERIC_READ | GENERIC_EXECUTE | DELETEが、かなり無意味です (ヒント: ファイル システム ACL に SYNCHRONIZE がないと、有効なアクセスができません) が、ACL から問題のあるエントリを削除できない理由がわかりません。

4

0 に答える 0