Im trying to move all files from "C:\SSIS\Test1\" that are new than 2 days old to the C:\SSIS\Test\" but for some reason it keeps skipping over the if statement marked in red.
Any help please. Very amateur programmer here!
Sub Text()
Dim sDay As DateTime
sDay = DateAdd(DateInterval.Day, -2, Date.Now)
Console.WriteLine(sDay)
Dim FSO As Object
'Dim FromPath As String
Dim ToPath As String
ToPath = "C:\SSIS\Test\"
Dim di As New DirectoryInfo("C:\SSIS\Test1\")
' Get a reference to each file in that directory.
Dim fiArr As FileInfo() = di.GetFiles()
' Display the names of the files.
Dim fri As FileInfo
For Each fri In fiArr
Console.WriteLine(fri.Name)
Try
FSO = CreateObject("scripting.filesystemobject")
If fri.Name > sDay Then 'skips over this part even when the file was just created
FSO.CopyFile(Source:=di, Destination:=ToPath)
End If
Catch ex As Exception
End Try
Next fri