本文整理汇总了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