Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:37:33+00:00 2026-06-01T11:37:33+00:00

I have written a tool to collect log files within a time window specified

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:37:35+00:00Added an answer on June 1, 2026 at 11:37 am

    During my experience I went throw a couple of issues like yours. On Windows Vista/7 systems that function not always returns a reliable result.

    After a while we found this link: Disabling Last Access Time in Windows Vista to improve NTFS performance

    An observant Windows Vista user noticed a registry named
    NtfsDisableLastAccessUpdate under
    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ControlFileSystem and asked
    us what this means.

    Last Access Time is a file attribute that’s
    updated when a file is accessed or otherwise touched. (This is often
    confused with the Last Modified Time, which is only updated when the
    file changes.) Last Access Time has a loose granularity that only
    guarantees that the time is accurate to within one hour.

    In Windows
    Vista, we’ve disabled updates to Last Access Time to improve NTFS
    performance. If you are using an application that relies on this
    value, you can enable it using the following command:

    fsutil behavior set disablelastaccess 0

    You must restart the computer for this change to take effect. For more information about the Fsutil command and Last Access Time,
    see the Fsutil online Help.

    Based on this it became clear that last access time can not be used as a “strong key”. To resolve that issue, we just stop relaying on GetLastWriteTime call, but store last changed value of the file or in its name, like "FileName_yyyymmdd", or inside that file in some field.

    There is another solution for GetLastAccessTime can find here:

    .NET FileInfo.LastWriteTime & FileInfo.LastAccessTime are wrong, could be useful in your case too.

    My general opinion on this would be: do not relay on that parameter, but invent something else in your architecture.

    Good luck

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a tool tip snippet, its throwing error like TOO MUCH RECURSION
I have a couple processes running a tool I've written that are joined by
I have written a tool that references Microsoft.TeamFoundation.VersionControl.Client.dll, which is a 32-bit DLL. When
I have written a tool for database replication in PHP. It's working fine but
I have written a tool that is run on the command line. I can
I have written a command-line tool that uses sub-commands much like Mercurial, Git, Subversion
I have written a simple framework (actually collection of libraries) and a number of
I have written a custom tool for Visual Studio, compiled to a VSIX and
I have written a C# tool that will launch an application by running a
I have a tool written in perl which is used by different users in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.