FileSystemSecurity.SetAccessRule(FileSystemAccessRule) FileSystemSecurity.SetAccessRule(FileSystemAccessRule) FileSystemSecurity.SetAccessRule(FileSystemAccessRule) FileSystemSecurity.SetAccessRule(FileSystemAccessRule) Method

定義

設定目前檔案或目錄之指定的存取控制清單 (ACL) 使用權限。Sets the specified access control list (ACL) permission for the current file or directory.

public:
 void SetAccessRule(System::Security::AccessControl::FileSystemAccessRule ^ rule);
public void SetAccessRule (System.Security.AccessControl.FileSystemAccessRule rule);
override this.SetAccessRule : System.Security.AccessControl.FileSystemAccessRule -> unit
Public Sub SetAccessRule (rule As FileSystemAccessRule)

參數

rule
FileSystemAccessRule FileSystemAccessRule FileSystemAccessRule FileSystemAccessRule

FileSystemAccessRule 物件,表示要為檔案或目錄設定的存取控制清單 (ACL) 使用權限。A FileSystemAccessRule object that represents an access control list (ACL) permission to set for a file or directory.

例外狀況

備註

方法會新增指定的存取控制清單 (ACL) 規則, 或覆寫任何FileSystemRights符合rule參數值的相同 ACL 規則。 SetAccessRuleThe SetAccessRule method adds the specified access control list (ACL) rule or overwrites any identical ACL rules that match the FileSystemRights value of the rule parameter. 例如, 如果rule參數Read指定值, 而SetAccessRule方法Read找到指定值的相同 ACL 規則, 則會覆寫相同的規則。For example, if the rule parameter specifies a Read value and the SetAccessRule method finds an identical ACL rule that specifies the Read value, the identical rule will be overwritten. 如果方法找到Write指定值的相同 ACL 規則, 將不會覆寫相同的規則。 SetAccessRuleIf the SetAccessRule method finds an identical ACL rule that specifies the Write value, the identical rule will not be overwritten.

若要將新的或變更的 ACL 資訊保存至檔案SetAccessControl , SetAccessControl請使用或方法。To persist new or changed ACL information to a file, use the SetAccessControl or SetAccessControl method. 若要將新的或變更的 ACL 資訊保存至目錄SetAccessControl , SetAccessControl請使用或方法。To persist new or changed ACL information to a directory, use the SetAccessControl or SetAccessControl method.

若要從檔案取出 ACL 資訊, 請使用GetAccessControlGetAccessControl方法。To retrieve ACL information from a file, use the GetAccessControl or GetAccessControl method. 若要從目錄取出 ACL 資訊, 請使用GetAccessControlGetAccessControl方法。To retrieve ACL information from a directory, use the GetAccessControl or GetAccessControl method.

適用於