本文整理汇总了VB.NET中System.DateTime.ToFileTime方法的典型用法代码示例。如果您正苦于以下问题:VB.NET DateTime.ToFileTime方法的具体用法?VB.NET DateTime.ToFileTime怎么用?VB.NET DateTime.ToFileTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.DateTime
的用法示例。
在下文中一共展示了DateTime.ToFileTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Main
Public Shared Sub Main()
System.Console.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.Console.WriteLine("{0} in file time is {1}.", _
fileCreationDateTime, _
fileCreationFileTime)
Else
System.Console.WriteLine("{0} is an invalid file", filePath)
End If
End Sub
示例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