Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can reproduce this using .NET 4.0 and 2.0/3.5 on XP/Win2k3/Vista.</p> <p>The issue is DST was in a different state to now, and .NET is processing this difference differently to Explorer and <code>Scripting.FileSystemObject</code>.</p> <p>(You can see a similar issue when extracting files from a zip file when DST is different to when the files were zipped.)</p> <p>Via Reflector, the reason .NET differs from the non .NET code paths is that all three local datestamps in <code>IO.File</code> (and <code>IO.FileInfo</code>) are implemented as getting the Utc datestamp and applying <code>.ToLocalTime</code>, which determines the offset to add based upon whether DST was happening in the local timezone <em>for the Utc time</em>.</p> <p>I also checked, by changing the date to July 1 last year, creating a file and watching the timestamp when I return to the current date (March 16) (I'm in South Australia, so we're in DST now and were not on July 1), and Windows (and presumably <code>FileSystemObject</code>) adds the DST in place <em>NOW</em> so the time displayed actually changes.</p> <p>So, in summary, .NET is more correct.</p> <p>But if you want the incorrect, but same as Explorer, date use:</p> <pre><code>Public Function GetLastAccessTime(ByVal FilePath As String) As Date Return IO.File.GetLastAccessTimeUtc(FilePath) _ .Add(TimeZone.CurrentTimeZone.GetUtcOffset(Now)) End Function </code></pre> <p>This has been discussed on <a href="http://blogs.msdn.com/b/oldnewthing/archive/2003/10/24/55413.aspx" rel="nofollow">Raymond Chen's blog</a> (where the summary is: .NET is intuitively correct but not always invertible, and Win32 is strictly correct and invertible).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload