由于您使用的是ToFileTime
,因此您需要使用FromFileTime走另一条路。但是注意:
Ordinarily, the FromFileTime method
restores a DateTime value that was
saved by the ToFileTime method.
However, the two values may differ
under the following conditions:
If the serialization and deserialization of the DateTime value occur in different time zones. For
example, if a DateTime value with a
time of 12:30 P.M. in the U.S. Eastern
Time zone is serialized, and then
deserialized in the U.S. Pacific Time
zone, the original value of 12:30 P.M.
is adjusted to 9:30 A.M. to reflect
the difference between the two time
zones.
If the DateTime value that is serialized represents an invalid time
in the local time zone. In this case,
the ToFileTime method adjusts the
restored DateTime value so that it
represents a valid time in the local
time zone.
如果您不关心DateTime的哪种长
表示形式被存储,您可以按照其他人的建议使用Ticks
(Ticks可能更可取,具体取决于您的要求,因为ToFileTime
返回的值似乎在Windows文件系统API的上下文中)。