Question : Windows Scripting: FileSystemObject properties inconsistent with Windows Explorer values

I have  some VBA code that loops through the files in a folder and copys a file to another location if it meets date criteria. I am finding that the DateCreated and DateLastModified of the files as returned by FileSystemObject (file.DateCreated, file.DateLastModified) disagree with the created and modified dates displayed in Windows Explorer. This is the case for all of the files I have compared in the folder I am working with. For example, for one of the files,

                      Explorer                    FileSystemObject
Created         1/4/2010                   12/31/2009
Modified         1/4/2010                   9/3/09

The values shown by Explorer are correct - I have no idea where the FileSystemObject values are coming from.

Does anyone have any idea what's going on here?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:

If Weekday(Date) = vbMonday Then
  CompareDate = DateAdd("d", -3, Date)
Else
  CompareDate = DateAdd("d", -1, Date)
End If
For Each f In fldr.Files
  If f.DateLastModified >= CompareDate Then
    FileCopy f, "c:\Test\" & f.Name
  End If
Next f

Answer : Windows Scripting: FileSystemObject properties inconsistent with Windows Explorer values

Agreed, your code is straight forward.  Not sure what the cause is, but I'll throw out a few more thoughts, questions.

How are you "displaying" the dates that the script sees for those files, with a msgbox, or some other way?  

Are you absolutely sure you are comparing the same file's dates in Explorer versus VBA (I know, I felt bad even asking it, but trying to check all possibilities)?

I assume H:\ is a network share drive?  If so, maybe that is part of the puzzle.  Have you tried doing a test against a file on say the C: drive to see if the same problem exists there?

Also, if H:\ is a network drive, could you try the code right on that server that hosts the file, as well as check it's timestamps with Explorer right on the box.

As another data point, try checking the timestamps from a CMD prompt as well to see what it agrees to.  The /T switch let's you see the various dates one by one, so you could do:

DIR /TC h:\testfile.txt
DIR /TW h:\testfile.txt

~bp
Random Solutions  
 
programming4us programming4us