FolderItem.ModificationDateTime

From Xojo Documentation

Property (As DateTime )
aFolderItem.ModificationDateTime = newDateTimeValue
or
DateTimeValue = aFolderItem.ModificationDateTime

Supported for all project types and targets.

The modification date and time of the FolderItem.

Notes

Because the DateTime class properties are all read-only, you cannot directly change the ModificationDateTime. It's instead by assigning to it an entirely new date. See the example below.

On Windows, the ModificationDate cannot be changed if the file is open. This includes if it is open using a BinaryStream, TextInputStream or TextOutputStream. Close the file before changing the ModificationDateTime.

Example

This example displays the modification date in the ShortDate format. In this case, the None format is specified for the Time format so that time is not included.

Var f As New FolderItem
f = FolderItem.ShowOpenFileDialog("")
If f <> Nil Then
MessageBox(f.ModificationDateTime.ToString(DateTime.FormatStyles.Short, DateTime.FormatStyles.None)
End If

To change the ModificationDateTime, you must create a new instance of a DateTime and assign it to the property. In this example, the user selects a file and the ModificationDateTime of that file is set to the current date time via DateTime.Now.

Var f As New FolderItem
f = FolderItem.ShowOpenFileDialog("")

If f <> Nil Then
f.ModificationDateTime = DateTime.Now
End If