IFileInputSelectedFile.LastModified Property
Returns the file’s last modified date.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v25.1.dll
NuGet Package: DevExpress.Blazor
Declaration
long LastModified { get; }
Property Value
Type | Description |
---|---|
Int64 | The number of ticks that corresponds to the date and time when the file was last modified. |
Remarks
The LastModified
property returns the number of ticks that corresponds to the date and time when the file was last modified. For files with an unknown last modified date, the property returns the number of ticks that corresponds to the current date.
Tip
A single tick in .NET is 100 nanoseconds (or one ten-millionth of a second).
The value of this property is calculated from the lastModified property of the JavaScript File
interface. Since the lastModified
returns the number of milliseconds, we use the following formula to convert it into ticks:
(inputFile.lastModified * 10000) + 621355968000000000
10000
is the number of .NET ticks in one millisecond.621355968000000000
is the number of .NET ticks betweenDateTime.MinValue
(00:00:00 on January 1, 0001) and the Unix epoch (00:00:00 on January 1, 1970). The JavaScriptFile.lastModified
property uses the Unix epoch as its baseline.
The following example gets last modified dates of uploaded files:
<DxFileInput FilesUploading="OnFilesUploading" />
@code {
async Task OnFilesUploading(FilesUploadingEventArgs args) {
foreach (var file in args.Files) {
DateTime lastModifiedTimestamp = new DateTime(file.LastModified);
// ...
/* The following code is intended for demonstration purposes only.
Do not read a stream directly in memory to avoid performance and security-related issues. */
using var stream = new System.IO.MemoryStream();
await file.OpenReadStream(file.Size).CopyToAsync(stream);
}
}
}