FolderItem.CreationDateTime

From Xojo Documentation

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

Supported for all project types and targets.

The creation date and time of the FolderItem.

Notes

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

On Windows, the CreationDateTime 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 CreationDateTime.

On Linux, the CreationDateTime cannot be modified. Attempting to change it raises an UnsupportedOperationException. Also, the CreationDateTime may not be accurate as many Linux file systems do NOT actually track the creation date.

Example

This example displays the creation 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
MessageBox(f.CreationDateTime.ToString(DateTime.FormatStyles.Short, DateTime.FormatStyles.None)

To change the CreationDateTime, 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 CreationDateTime 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.CreationDateTime = DateTime.Now
End If