Compartir a través de


IBasicFileAttributeView.SetTimes(FileTime, FileTime, FileTime) Method

Definition

Updates any or all of the file's last modified time, last access time, and create time attributes.

[Android.Runtime.Register("setTimes", "(Ljava/nio/file/attribute/FileTime;Ljava/nio/file/attribute/FileTime;Ljava/nio/file/attribute/FileTime;)V", "GetSetTimes_Ljava_nio_file_attribute_FileTime_Ljava_nio_file_attribute_FileTime_Ljava_nio_file_attribute_FileTime_Handler:Java.Nio.FileNio.Attributes.IBasicFileAttributeViewInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public void SetTimes (Java.Nio.FileNio.Attributes.FileTime? lastModifiedTime, Java.Nio.FileNio.Attributes.FileTime? lastAccessTime, Java.Nio.FileNio.Attributes.FileTime? createTime);
[<Android.Runtime.Register("setTimes", "(Ljava/nio/file/attribute/FileTime;Ljava/nio/file/attribute/FileTime;Ljava/nio/file/attribute/FileTime;)V", "GetSetTimes_Ljava_nio_file_attribute_FileTime_Ljava_nio_file_attribute_FileTime_Ljava_nio_file_attribute_FileTime_Handler:Java.Nio.FileNio.Attributes.IBasicFileAttributeViewInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member SetTimes : Java.Nio.FileNio.Attributes.FileTime * Java.Nio.FileNio.Attributes.FileTime * Java.Nio.FileNio.Attributes.FileTime -> unit

Parameters

lastModifiedTime
FileTime

the new last modified time, or null to not change the value

lastAccessTime
FileTime

the last access time, or null to not change the value

createTime
FileTime

the file's create time, or null to not change the value

Attributes

Remarks

Updates any or all of the file's last modified time, last access time, and create time attributes.

This method updates the file's timestamp attributes. The values are converted to the epoch and precision supported by the file system. Converting from finer to coarser granularities result in precision loss. The behavior of this method when attempting to set a timestamp that is not supported or to a value that is outside the range supported by the underlying file store is not defined. It may or not fail by throwing an IOException.

If any of the lastModifiedTime, lastAccessTime, or createTime parameters has the value null then the corresponding timestamp is not changed. An implementation may require to read the existing values of the file attributes when only some, but not all, of the timestamp attributes are updated. Consequently, this method may not be an atomic operation with respect to other file system operations. Reading and re-writing existing values may also result in precision loss. If all of the lastModifiedTime, lastAccessTime and createTime parameters are null then this method has no effect.

<b>Usage Example:</b> Suppose we want to change a file's last access time.

Path path = ...
               FileTime time = ...
               Files.getFileAttributeView(path, BasicFileAttributeView.class).setTimes(null, time, null);

Java documentation for java.nio.file.attribute.BasicFileAttributeView.setTimes(java.nio.file.attribute.FileTime, java.nio.file.attribute.FileTime, java.nio.file.attribute.FileTime).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to