File modified date problem

J

Just Me

I'm trying to write some code to determine if two copies of a file
stored on two different drives are identical. I thought this would be
fairly easy by checking the file length and the modified date. In doing
this I found that if I copy a file to a different location on the same
drive, the modified date stays the same. But if I copy the file to a
different drive the modified date is changed by a second or two. I've
tried this numerous times with different variations and always get the
same results - copy a file to the same drive, same modified date; copy
it to a different drive and you now you have different modified dates.
I see the same results whether I check it using FileDateTime or
DateLastModified. In Windows Explorer you don't notice this because it
doesn't show the seconds.

So now my questions...
Does this happen to everyone else too?
Why would Microsoft do this? (I know - a stupid question.)
How can I determine if files on different drives are the same when the
modified date changes even when the file hasn't been modified? I can't
rely on file length alone because it is possible to change a file and
have its length remain the same. I can't do a comparison of the file
contents because there are many files to check and it would probably
take forever.

Any suggestions would be greatly appreciated.
Tony
 
J

Jim Cone

Wouldn't something like this faux code do the job ...
If Abs(FileOne.ModifiedDate - FileTwo.ModifiedDate) < 3 Seconds and _
FileOne.Length = FileTwo.Length Then
Files are the Same
End If
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Just Me" <[email protected]>
wrote in message
I'm trying to write some code to determine if two copies of a file
stored on two different drives are identical. I thought this would be
fairly easy by checking the file length and the modified date. In doing
this I found that if I copy a file to a different location on the same
drive, the modified date stays the same. But if I copy the file to a
different drive the modified date is changed by a second or two. I've
tried this numerous times with different variations and always get the
same results - copy a file to the same drive, same modified date; copy
it to a different drive and you now you have different modified dates.
I see the same results whether I check it using FileDateTime or
DateLastModified. In Windows Explorer you don't notice this because it
doesn't show the seconds.

So now my questions...
Does this happen to everyone else too?
Why would Microsoft do this? (I know - a stupid question.)
How can I determine if files on different drives are the same when the
modified date changes even when the file hasn't been modified? I can't
rely on file length alone because it is possible to change a file and
have its length remain the same. I can't do a comparison of the file
contents because there are many files to check and it would probably
take forever.

Any suggestions would be greatly appreciated.
Tony
 
J

Just Me

I'll probably end up doing something like that and possibly using the
archive attribute. But I'd still like to know why the date modified is
slightly changed when a file is copied to a different drive - if anyone
knows.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top