Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - Compare timespan of Files?

Reply
 
Old 05-07-2008   #1 (permalink)
Daniel Di Vita


 
 

Compare timespan of Files?

II want to compare how many seconds there are between files. If the files are
within a 1 - 10 second range I want to copy them to their own folders. What I
have so far is a couple methods that take in all the files in a directory /
subdirectories and sort them by their lastWriteTime stamp:

Dim flist As List(Of System.IO.FileInfo)
Private Sub writeDirectories(ByVal ParentPath As String)
For Each sDirectory As String In
System.IO.Directory.GetDirectories(ParentPath)
flist.AddRange(New DirectoryInfo(sDirectory).GetFiles())

writeDirectories(sDirectory)

Next
End Sub

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
flist = New List(Of System.IO.FileInfo)
writeDirectories("C:\Documents and Settings\ddivita\My Documents")
flist.Sort(AddressOf SortByLastWriteTime)
End Sub

Private Function SortByLastWriteTime(ByVal x As System.IO.FileInfo, ByVal y
As System.IO.FileInfo) As Integer
Return x.LastWriteTime.CompareTo(y.LastWriteTime)
End Function

I then want to take the flist and compare the TimeSpan between files. Here
is an example:

File1 - TimeStamp - 5:16:46
File2 - TimeStamp - 5:16:50
File3 - TimeStamp - 5:16:54
File4 - TimeStamp - 3:56:37
File5 - TimeStamp - 3:56:42

I realize I would need to compare file1 to file2, then file2 to file3, and
so on. I figure I could use the timespan class to help with this. Any ideas?
Thanks

Daniel

My System SpecsSystem Spec
Old 05-08-2008   #2 (permalink)
Cor Ligthert[MVP]


 
 

Re: Compare timespan of Files?

Daniel,

First of all, you have to examine what you mean with this sentence.
Quote:

> II want to compare how many seconds there are between files.
The fileinfo has 3 times, (2 properties are to give back times in Zulu)

http://msdn.microsoft.com/en-us/libr...o_members.aspx

Then you can use of course the timespan class in your list.

http://msdn.microsoft.com/en-us/libr...an(vs.85).aspx

Have only a look at the bottom of the sample, as the top direct starts to
confuse.

Cor

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Re: ignore whitespace when comparing files using compare-object? PowerShell
Re: ignore whitespace when comparing files using compare-object? PowerShell
Compare files and get the differential PowerShell
Compare 2 files with 6,000 entries each PowerShell
Comparing files with compare-object PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46