edpatterson
IS-IT--Management
- Feb 24, 2005
- 186
I am trying to determine if a file has been modified since a script last ran. The last modification date information is stored in a text file. When the script runs it reads the file and checks that value against a objFile.DateLastModified call. The last modified date in the file is identical to the one returned yet the comparison fails.
Even though the values are identical (as far as I can see) the <> tests positive.
Perhaps I have simply looked at it too long.
Ed
Code:
Option Explicit
Dim strFilein, strLinein, strTestTime
Dim dicFileData
Dim intCount
Dim objFSO, objTSO, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTSO = objFSO.CreateTextFile("test.txt")
objTSO.Close
Set objTSO = objFSO.CreateTextFile("test2.txt")
Set objFile = objFSO.GetFile("test.txt")
strTestTime = cdate(objFile.DateLastModified)
objTSO.WriteLine strTestTime
objTSO.Close
Set objTSO = objFSO.OpenTextFile("test2.txt")
strLinein = Trim(objTSO.ReadLine)
' In theory strLinein = objFile.DateLastModified
If strLinein <> CDate(objFile.DateLastModified) Then
WScript.Echo "They are different"
WScript.Echo strLinein&"."
WScript.Echo CDate(objFile.DateLastModified)&"."
Else
WScript.Echo "They are the same"
End If
Perhaps I have simply looked at it too long.
Ed