Files.SetLastModifiedTime(IPath, FileTime) Method
Definition
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 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 given path
- Attributes
Exceptions
if an I/O error occurs
In the case of the default provider, and a security manager is installed, its checkWrite method denies write access to the file.
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.
Usage Example: 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);
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.