本文整理匯總了VB.NET中System.DateTime.FromFileTime方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET DateTime.FromFileTime方法的具體用法?VB.NET DateTime.FromFileTime怎麽用?VB.NET DateTime.FromFileTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.DateTime
的用法示例。
在下文中一共展示了DateTime.FromFileTime方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: FileAge
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
示例2: Example
Module Example
Public Sub Main()
Dim date1 As New DateTime(2010, 3, 14, 2, 30, 00)
Console.WriteLine("Invalid Time: {0}", TimeZoneInfo.Local.IsInvalidTime(date1))
Dim ft As Long = date1.ToFileTime()
Dim date2 As DateTime = DateTime.FromFileTime(ft)
Console.WriteLine("{0} -> {1}", date1, date2)
End Sub
End Module
輸出:
Invalid Time: True 3/14/2010 2:30:00 AM -> 3/14/2010 3:30:00 AM