FileStream.SetAccessControl(FileSecurity) FileStream.SetAccessControl(FileSecurity) FileStream.SetAccessControl(FileSecurity) Method

定义

FileSecurity 对象所描述的访问控制列表 (ACL) 项应用于当前 FileStream 对象所描述的文件。Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileStream object.

public:
 void SetAccessControl(System::Security::AccessControl::FileSecurity ^ fileSecurity);
public void SetAccessControl (System.Security.AccessControl.FileSecurity fileSecurity);
member this.SetAccessControl : System.Security.AccessControl.FileSecurity -> unit

参数

fileSecurity
FileSecurity FileSecurity FileSecurity

描述要应用于当前文件的 ACL 项的对象。An object that describes an ACL entry to apply to the current file.

异常

fileSecurity 参数为 nullThe fileSecurity parameter is null.

未能找到或修改该文件。The file could not be found or modified.

当前进程不具有打开该文件的权限。The current process does not have access to open the file.

注解

虽然FileStream类和SetAccessControl可对现有文件,请考虑使用File.SetAccessControl方法,因为它是易于使用。While the FileStream class and SetAccessControl can be used on an existing file, consider using the File.SetAccessControl method as it is easier to use.

SetAccessControl方法适用于表示非继承的 ACL 列表的文件的访问控制列表 (ACL) 项。The SetAccessControl method applies access control list (ACL) entries to a file that represents the noninherited ACL list.

注意

为 ACL 指定fileSecurity参数将替换现有文件 ACL。The ACL specified for the fileSecurity parameter replaces the existing ACL for the file. 若要添加新用户的权限,请使用GetAccessControl方法以获取现有 ACL,对其进行修改,然后使用SetAccessControl以将其应用到的文件。To add permissions for a new user, use the GetAccessControl method to obtain the existing ACL, modify it, and then use SetAccessControl to apply it back to the file.

ACL 描述个人和/或组具有或没有执行到对给定文件的特定操作的权限。An ACL describes individuals and/or groups who have, or do not have, rights to specific actions on the given file. 有关详细信息,请参阅如何:添加或移除访问控制列表项For more information, see How to: Add or Remove Access Control List Entries.

适用于