Hello,
I'm writing code to programatically compare the last write time of files in two directories.
I have written the following to obtain the list of files from the two directories
For Each oldf As String In System.IO.Directory.GetFiles(oldpath)
Dim oldfilename As String = oldf.Substring(oldf.LastIndexOf("\") + 1)
Dim oldfilenametime As DateTime = System.IO.File.GetLastWriteTime(oldf)
'ListBox1.Items.Add(((oldfilename) & " " & (oldfilenametime)).ToString)
Next
For Each newf As String In System.IO.Directory.GetFiles(newpath)
Dim newfilename As String = newf.Substring(newf.LastIndexOf("\") + 1)
Dim newfilenametime As DateTime = System.IO.File.GetLastWriteTime(newf)
'ListBox2.Items.Add(((newfilename) & " " & (newfilenametime)).ToString)
Next
I tested it by adding the results to list boxes and it works....however now I am not sure how to compare the two files time and display something like "file A is newer than file B" or "file A is older than file B".
Can anybody offer some help doing this?
Thanks
I'm writing code to programatically compare the last write time of files in two directories.
I have written the following to obtain the list of files from the two directories
For Each oldf As String In System.IO.Directory.GetFiles(oldpath)
Dim oldfilename As String = oldf.Substring(oldf.LastIndexOf("\") + 1)
Dim oldfilenametime As DateTime = System.IO.File.GetLastWriteTime(oldf)
'ListBox1.Items.Add(((oldfilename) & " " & (oldfilenametime)).ToString)
Next
For Each newf As String In System.IO.Directory.GetFiles(newpath)
Dim newfilename As String = newf.Substring(newf.LastIndexOf("\") + 1)
Dim newfilenametime As DateTime = System.IO.File.GetLastWriteTime(newf)
'ListBox2.Items.Add(((newfilename) & " " & (newfilenametime)).ToString)
Next
I tested it by adding the results to list boxes and it works....however now I am not sure how to compare the two files time and display something like "file A is newer than file B" or "file A is older than file B".
Can anybody offer some help doing this?
Thanks