System Namespace DateTime Structure
Returns a DateTime equivalent to the specified operating system file timestamp.
[ VB ]
<Serializable>
Public Shared Function FromFileTime ( _
ByVal fileTime As Long _
} As DateTime
[ C# ]
[ Serializable ]
public static DateTime FromFileTime (
long fileTime
};
[ C++ ]
[ Serializable ]
public: static DateTime FromFileTime (
__int64 fileTime
};
[ JScript ]
public Serializable
static function FromFileTime (
fileTime : long
} : DateTime;
- fileTime
- A Windows file time.
A DateTime value representing the date and time of fileTime, adjusted to local time.
fileTime is a 64-bit signed integer value representing a Windows file timestamp. The timestamp is the number of 100-nanosecond intervals that have elapsed since January 1, 1601 12:00 A.M. coordinated universal time ( UTC ).
The below code snippet demonstrates using the FromFileTime method.
public System.TimeSpan FileAge ( long fileCreationTime ) {
System.DateTime now = System.DateTime.Now;
try {
System.DateTime fCreationTime =
System.DateTime.FromFileTime ( fileCreationTime );
System.TimeSpan fileAge = now.Subtract ( fCreationTime );
return fileAge;
}
catch ( ArgumentOutOfRangeException ) {
// fileCreationTime is not valid, so re-throw the exception.
throw;
}
}
Public Function FileAge ( ByVal fileCreationTime As Long ) As System.TimeSpan
Dim now As System.DateTime
now = System.DateTime.Now
Try
Dim fCreationTime As System.DateTime
Dim fAge As System.TimeSpan
fCreationTime = System.DateTime.FromFileTime ( fileCreationTime )
fAge = now.Subtract ( fCreationTime )
Return fAge
Catch exp As ArgumentOutOfRangeException
' fileCreationTime is not valid, so re-throw the exception.
Throw
End Try
End Function |
|
C# |
VB |
DateTime Members ToUniversalTime GetUtcOffset