System Namespace DateTime Structure
Converts the value of this instance to the format of the local system file time.
[ VB ]
<Serializable>
Public Function ToFileTime ( ) As Long
[ C# ]
[ Serializable ]
public long ToFileTime ( );
[ C++ ]
[ Serializable ]
public: __int64 ToFileTime ( );
[ JScript ]
public Serializable
function ToFileTime ( ) : long;
The value of this DateTime in the format of the local system file time.
A system file time is a 64-bit unsigned value representing the date and time as the number of 100-nanosecond intervals that have elapsed since January 1, 1601 12:00 A.M.
An exception is thrown if you attempt to convert a date earlier than January 1, 1601 12:00:00 A.M. coordinated universal time ( UTC ).
The below code snippet demonstrates using the ToFileTime.
[ VB ]
Overloads Shared Sub Main ( ByVal args ( ) As String )
System.Response.WriteLine ( "Enter the file path:" )
Dim filePath As String
filePath = System.Console.ReadLine ( )
If System.IO.File.Exists ( filePath ) Then
Dim fileCreationDateTime As System.DateTime
fileCreationDateTime = System.IO.File.GetCreationTime ( filePath )
Dim fileCreationFileTime As Long
fileCreationFileTime = fileCreationDateTime.ToFileTime ( )
System.Response.WriteLine ( "{ 0 } in file time is { 1 }.", _
fileCreationDateTime, _
fileCreationFileTime )
Else
System.Response.WriteLine ( "{ 0 } is an invalid file", filePath )
End If
End Sub
[ C# ]
static void Main ( string [ ] args )
{
System.Response.WriteLine ( "Enter the file path:" );
string filePath = System.Console.ReadLine ( );
if ( System.IO.File.Exists ( filePath ) ) {
System.DateTime fileCreationDateTime =
System.IO.File.GetCreationTime ( filePath );
long fileCreationFileTime = fileCreationDateTime.ToFileTime ( );
System.Response.WriteLine ( "{ 0 } in file time is { 1 }.",
fileCreationDateTime,
fileCreationFileTime );
}
else {
System.Response.WriteLine ( "{ 0 } is an invalid file", filePath );
}
}
DateTime Members Int64 ToUniversalTime GetUtcOffset