I have written a tool to collect log files within a time window specified by the user of the tool. Up until now I was basing the collection of log files by using the File.GetLastWriteTime method on the log files, comparing this to the times the user entered and collecting based on the outcome of these comparisions. Here is a small code snippet:
DateTime logFileEnd = File.GetLastWriteTime(matchingActiveLogFile);
However I noticed my tool didnt collect some log files I thought it should have done. It seems the DateTime returned by this method was out of date, (there was more recent logging in the file than the value of this datetime).
When I looked at the 'Date Modified' of the file in question, it too was 'out of date', there was more recent logging in the file than the 'Date Modified'.
How I can I get an accurate 'GetLastWriteTime' or Date Modified value?