winXP、win7、vb.net下时间戳不同
在 VB.net 程序中,我使用 IO.File.GetCreationTime 来读取文件系统的文件创建时间。我很生气,因为返回的值与资源管理器中显示的时间不匹配。在另一台机器上时间显示正确。
- 两台机器都使用 NTFS
- 我将文件从只读 FAT32 USB 驱动器复制到每台机器的桌面
- 两台机器都使用相同的时区(GMT+1 加 DST)
显示时间戳:
- 我的 VB.net 应用程序(两台机器) - 21:09
- 资源管理器时间 Windows XP - 22:09
- 资源管理器时间 Windows 7 - 21:09
- (MacOS X - 21:09)
好处是,我正在谈论的文件是 PDF 文件。根据 PDF 的元信息,该文件于03 创建。 Jan. 2002 22:09
我希望每台计算机上的文件系统日期都相同。 您将如何使用 VB.net 解决这个问题?
Within a VB.net program I used IO.File.GetCreationTime to read the file system's creation time of a file. I was irritated, because the returned value didn't match with the time displayed in the explorer. On another machine the time was displayed correctly.
- Both machines use NTFS
- I copied the file from a read-only FAT32 USB-drive to the desktop of each machine
- Both machines are using the same time zone (GMT+1 plus DST)
timestamps displayed:
- my VB.net app (both machines) - 21:09
- Explorer time Windows XP - 22:09
- Explorer time Windows 7 - 21:09
- (MacOS X - 21:09)
The good thing is, that the file I'm talking about is a PDF file. According to the PDF's meta information the file was created on 03. Jan. 2002 22:09
I want that the file system dates are the same on every machine.
How would you solve this problem using VB.net?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我使用一个简单的应用程序来总结时间戳信息:
两台机器上的输出相同。
由于某种原因,我更改了两台计算机上的时区设置,打开和关闭 DST。结果很有趣……
XP 所有时间戳减少
一(因为在 DST 期间我的时区
是GMT+2(现在),期间
冬季时间为 GMT+1)
在夏令时 (GMT+2) 期间创建的文件
受此影响(我的文件是
一月创建)
我想反之亦然是同样的效果。所以我的问题只是一个显示问题。为了解决这个问题,我将只使用 UTC 函数并关心我的应用程序中的 DST。所以还是会有偏移,不过只要是显示问题就应该没问题。
I used a simple app to summarize the timestamp information:
The output was the same on both machines.
For some reason I changed the time zone settings on both machines, switching DST on and off. The result is interesting ...
XP all time stamps are reduced by
one (because during DST my time zone
is GMT+2 (now), during the
wintertime it is GMT+1)
files created during DST (GMT+2)
are affected by this (my file was
created in January)
I guess it's the same effect vice versa. So my problem is just a disply issue. To solve this I will only use the UTC-Functions and care about DST within my app. So there still will be an offset, but it should be ok as long as it is just a display issue.