Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
the new last modified time, or null
to not change the
value
the last access time, or null
to not change the value
the file's create time, or null
to not change the value
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);
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.
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in