.NET FileInfo.LastWriteTime & FileInfo.LastAccessTime are wrong

The FileInfo values are only loaded once and then cached. To get the current value, call Refresh() before getting a property:

f.Refresh();
t = f.LastAccessTime;

Another way to get the current value is by using the static methods on the File class:

t = File.GetLastAccessTime(path);

Leave a Comment