파일 시스템 및 사용 권한/권한 액세스 (액세스 제어 목록, ACL)가 새로 도입되었습니다. ACL과 관련하여 코딩하는 동안 파일에 원하는 속성을 설정할 수 없습니다. FileSystemRights 회원에 대한 나의 이해가 잘못되었거나 완전히 잘못하고있는 것이 확실하지 않습니다. (그리고 나는 이미이 부분에 대해 꽤 많은 시간을 보내고있다.)FileSystemRights 문제 (C#)
내가하고 싶은 것은 파일의 읽기 권한 만 바꿀 수 있고 편집, 이름 변경, 삭제 및 삭제할 수 없도록 파일의 권한을 변경하는 것이다. 다른 곳에 복사했다.
- 추가 수정 권한을 (.Modify을 거부 읽을 수 없게 파일의 원인이됩니다) 거부 :
try { //Get current identity WindowsIdentity self = System.Security.Principal.WindowsIdentity.GetCurrent(); // Add the access control entry to the file. AddFileSecurity(filename, self.Name, FileSystemRights.Modify, AccessControlType.Deny); AddFileSecurity(filename, self.Name, FileSystemRights.Write, AccessControlType.Deny); AddFileSecurity(filename, self.Name, FileSystemRights.ReadAndExecute, AccessControlType.Allow); // Remove the access control entry from the file. RemoveFileSecurity(filename, self.Name, FileSystemRights.ReadAndExecute, AccessControlType.Deny); RemoveFileSecurity(filename, self.Name, FileSystemRights.Read, AccessControlType.Deny); Console.WriteLine("Done."); } catch (Exception e) { Console.WriteLine(e); }
내 논리가 있다는 것입니다 :은 MSDN의 예제를 사용
, 여기에 내가 지금까지 가지고 무엇을 - 추가 ReadAndExecute 권한
- 제거는 항목을 거부 허용 추가 쓰기 권한을
- 거부
- 제거 (.Modify이 ReadAndExecute 거부로) ReadAndExecute에 (.Modify 읽기를 거부로)
내가 제대로이 부분을하고 있는가 읽기에 대한 항목을 거부? 그렇지 않은 경우 파일을 읽기 전용으로 만 만들고 편집 가능하고 이름을 바꿀 수 있고 삭제 가능하며 복사 할 수 없게하려면 어떻게해야하는지 알려주십시오. 미리 많은 감사드립니다!
파일을 읽을 수있는 한 항상 복사 할 수 있습니다! – Yahia
그렇다면 어떤 종류의 해결 방법이라도 읽을 수있게 만들지 만 다른 곳에 복사하지 못하도록 할 수 있습니까? –
아니요 - 읽을 수있는 모든 항목을 복사 할 수 있습니다 ... – Yahia