Search code examples
c#windowsbackupntfs

Is it reliable to use Last Modified timestamp of directory while doing a backup?


I'm designing a simple incremental backup tool. Is it possible, that after I modify contents of directory, the "Last Modified" attribute of this directory will stay intact? The reason might be a NTFS glitch or bug, I don't know.

I found out there is an option NtfsDisableLastAccessUpdate. Is it also possible to turn off modification timestamp update?

I want to know how reliable this attribute is, so I can decide if it's a good idea to use it to make backups of filesystem.

I'm using FileSystemInfo.LastWriteTime to extract that information in C#.


Solution

  • I do not think, the last modified timestamp is reliable.

    The timestamp is decided by what file system that you are using.

    E.g. FAT32 uses the local timestamp when dealing with modified/created time.

    while NTFS uses the UTC timezone.

    Also, FAT32 has around 2 second resolution for last write times. That means it cannot accurately record the last modified date to seconds.

    Also, when you are copying files from FAT32 to NTFS , you see whole bunch of other timestamp problems.

    There are rules how timestamp are decided by the filesystems

    Moreover , you could change the timestamp of any files and folders using third party tools easily.