473,412 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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
Jun 27 '08 #1
1 1356
Daniel,

First of all, you have to examine what you mean with this sentence.
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

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Russ Green | last post by:
How does this: public TimeSpan Timeout { get { return timeout; } set { timeout = value; if(timeout < licenseTimeout) licenseTimeout = timeout; }
2
by: dale zhang | last post by:
Hi, I have a MS access DB with some users signed in at different dates. I want to check the DB daily to compare everyone’s timestamp against current date to find who’s in our DB for more...
3
by: James | last post by:
Hi Guys, Just looking for the best way to compare two times. What I want to do is make sure a time is in between two other times. E.g. If the current time is 14.00 I want to check that it is...
13
by: sd00 | last post by:
Hi all, can someone give me some coding help with a problem that *should* be really simple, yet I'm struggling with. I need the difference between 2 times (Target / Actual) However, these times...
3
by: Mark | last post by:
I'd like to compare two datetime values in milliseconds. The datetime.compare method appears to show only seconds. Milliseconds of a datetime are available as a property of each datetime, but I...
3
by: ChrisB | last post by:
Hello, I was wondering what the easiest way is to compare two DateTime objects and not have the time components be included in the comparision. For, example, if time1 = 10/01/07 9:00 am, and...
1
by: Will | last post by:
This little puzzle has been bugging me for some time. I'm trying to create a little service that will check a time frame and compare it to another timeframe (start / stop time). A real-world...
3
by: Curious | last post by:
I have code below. But it won't compile. Error: Cannot implicitly convert type 'System.TimeSpan' to 'System.DateTime' DateTime now = DateTime.Now.TimeOfDay; DateTime openTime =...
25
by: Brian | last post by:
I have a datetimepicker formated for just time, the user selects the time. I want to compare if that time is between midnight and 8 am dtmTime #11:59:59 PM# and dtmTime < #08:00:00 AM# this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.