I'm building a back-up program. It will check to see if the target file first exists (file has already been backed up) then it checks the "Last Modified" date of the source and target files (to see if source is newer and needs to be backed up). I'm pretty sure this worked in testing, now it's not.
vb.net Code:
If IO.File.Exists(TargetFile) Then MsgBox(TargetFileInfo.LastWriteTime & " , " & SourceFileInfo.LastWriteTime) If TargetFileInfo.LastWriteTime < SourceFileInfo.LastWriteTime Then SaveFile(SourceFile, TargetFile, "Over Written File:", True) Else SaveFile(SourceFile, TargetFile, "Exsisting File:", False) End If Else If TargetFileInfo.Directory.Exists = False Then IO.Directory.CreateDirectory(TargetFileInfo.Directory.ToString) SaveFile(SourceFile, TargetFile, "New File:", True) End If
The MSGBOX before the if statement is used for debugging. So I can see if they match. Now everytime this runs (even if dates match) it still over writes file. Its still saying Target date is less than Source date. I tried changing the "<" to "<>" still nothing. Am I implementing this wrong?




Reply With Quote