Unbelievable strange file creation time problem

I recently ran into the same problem described in the question. In our case, if our log file is older than a week, we delete it and start a new one. However, it's been keeping the same date created since 2008.

One answer here describes renaming the old file and then creating a new one, hopefully picking up the proper Creation Date. However, that was unsuccessful for us, it kept the old date still.

What we used was the File.SetCreationTime method, and as its name suggests, it easily let us control the creation date of the file, allowing us to set it to DateTime.Now. The rest of our logic worked correctly afterwards.


This is the result of an arcane "feature" going way back to the old days of Windows. The core details are here:

Windows NT Contains File System Tunneling Capabilities (Archive)

Basically, this is on purpose. But it's configurable, and an anachronism in most of today's software.

I think you can create a new filename first, then rename old->old.1, then new->old, and it'll "work". I don't remember honestly what we did when we ran into this last a few years back.


File.SetCreationTime("file", DateTime.Now);