Freigeben über


Files.SetLastModifiedTime(IPath, FileTime) Method

Definition

Updates a file's last modified time attribute.

[Android.Runtime.Register("setLastModifiedTime", "(Ljava/nio/file/Path;Ljava/nio/file/attribute/FileTime;)Ljava/nio/file/Path;", "", ApiSince=26)]
public static Java.Nio.FileNio.IPath? SetLastModifiedTime (Java.Nio.FileNio.IPath? path, Java.Nio.FileNio.Attributes.FileTime? time);
[<Android.Runtime.Register("setLastModifiedTime", "(Ljava/nio/file/Path;Ljava/nio/file/attribute/FileTime;)Ljava/nio/file/Path;", "", ApiSince=26)>]
static member SetLastModifiedTime : Java.Nio.FileNio.IPath * Java.Nio.FileNio.Attributes.FileTime -> Java.Nio.FileNio.IPath

Parameters

path
IPath

the path to the file

time
FileTime

the new last modified time

Returns

the path

Attributes

Remarks

Updates a file's last modified time attribute. The file time is 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 the last modified time when it is not supported by the file system or is outside the range supported by the underlying file store is not defined. It may or not fail by throwing an IOException.

<b>Usage Example:</b> Suppose we want to set the last modified time to the current time:

Path path = ...
               FileTime now = FileTime.fromMillis(System.currentTimeMillis());
               Files.setLastModifiedTime(path, now);

Java documentation for java.nio.file.Files.setLastModifiedTime(java.nio.file.Path, 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