Files.SetOwner(IPath, IUserPrincipal) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
更新文件所有者。
[Android.Runtime.Register("setOwner", "(Ljava/nio/file/Path;Ljava/nio/file/attribute/UserPrincipal;)Ljava/nio/file/Path;", "", ApiSince=26)]
public static Java.Nio.FileNio.IPath? SetOwner(Java.Nio.FileNio.IPath? path, Java.Nio.FileNio.Attributes.IUserPrincipal? owner);
[<Android.Runtime.Register("setOwner", "(Ljava/nio/file/Path;Ljava/nio/file/attribute/UserPrincipal;)Ljava/nio/file/Path;", "", ApiSince=26)>]
static member SetOwner : Java.Nio.FileNio.IPath * Java.Nio.FileNio.Attributes.IUserPrincipal -> Java.Nio.FileNio.IPath
参数
- path
- IPath
文件的路径
- owner
- IUserPrincipal
新文件所有者
返回
给定路径
- 特性
例外
如果关联的文件系统不支持 FileOwnerAttributeView,则为
如果出现 I/O 错误,则为
对于默认提供程序,并且安装了安全管理器,它将拒绝 RuntimePermission(“accessUserInformation”)或其 checkWrite 方法拒绝对文件的写入访问。
注解
更新文件所有者。
该 path 参数与支持 FileOwnerAttributeView.. 此文件属性视图提供对文件属性的访问权限,该属性是文件的所有者。
用法示例: 假设我们要使“joe”成为文件的所有者:
Path path = ...
UserPrincipalLookupService lookupService =
provider(path).getUserPrincipalLookupService();
UserPrincipal joe = lookupService.lookupPrincipalByName("joe");
Files.setOwner(path, joe);
Java文档java.nio.file.Files.setOwner(java.nio.file.Path, java.nio.file.attribute.UserPrincipal)。
本页的某些部分是根据 创建和共享的工作进行的修改,并根据 许可证中所述的条款使用。