I have an application that reads 'timed' data out of a file; currently, my input is something like this:
-- EDIT -- I have found an actual case where this fails.
0:0:1:934 > >> GOOD MORNING.<br>
But I seem to be having some trouble parsing this into a valid TimeSpan. I would appreciate if someone could point me in the right direction, as not many offerings that I've found thus far provided much in the way of solving the problem.
As my code stands;
String StoredTime = ArchiveLine.Split('>')[0].TrimEnd();
String StoredFrame = ArchiveLine.Substring(ArchiveLine.IndexOf('>')+1).TrimStart();
TimeSpan FrameTime = TimeSpan.Parse(StoredTime, DateTimeFormatInfo.InvariantInfo);
And it throws a format exception.
Thanks.
It may be a localisation issue. Some cultures use a comma instead of a period as the decimal point. Try:
TimeSpan FrameTime = TimeSpan.Parse(StoredTime, DateTimeFormatInfo.InvariantInfo);