every time i create a FileInfo object and access it’s lastaccesstime property, it’s always a few minutes off. the file property window remains constant, however the application shows that it is usually a few minutes after the property window time.
Also, i noticed that if i drag the file to the cmd window to pass the filename as an argument, the access time updates most of the time, but not always.
What could be causing this ?
below is an example:
static void Main(string[] args) { if (args.Length > 0) { FileInfo fi = new FileInfo(args[0].ToString()); Console.WriteLine(args[0]); if (fi.Exists) { Console.Write('Current: ' + DateTime.Now + '\n'); Console.Write('LAT: ' + fi.LastAccessTime + '\n'); Console.Write('LWT: ' + fi.LastWriteTime + '\n'); Console.Write('CT: ' + fi.CreationTime + '\n'); } Console.ReadKey(); } }
alt text http://img407.imageshack.us/img407/4728/propertiesox6.png alt text http://img380.imageshack.us/img380/7752/appgt0.png
In my experience, last access time is notoriously unreliable. According to http://technet.microsoft.com/en-us/library/cc781134.aspx…
Apparently, the in-memory copy will be correct, but in my experience, you may get a cached value which may be out of date. Also, note that last access time may be turned off by the user, and is turned off by default in Vista and 2008.