public static TimeSpan
GetDssDuration(string fileName)
{
const
int durationOffset = 62;
const
int durationLength = 6;
const
int headerLength = durationOffset +
durationLength;
using
(var fileStream = File.OpenRead(fileName))
{
var
fileHeader = new byte[headerLength
+ 1];
fileStream.Read(fileHeader, 0,
headerLength);
var
hoursData = new byte[2];
var
minutesData = new byte[2];
var
secondsData = new byte[2];
Array.Copy(fileHeader,
durationOffset, hoursData, 0, 2);
Array.Copy(fileHeader,
durationOffset + 2, minutesData, 0, 2);
Array.Copy(fileHeader,
durationOffset + 4, secondsData, 0, 2);
return
new TimeSpan(int.Parse(Encoding.ASCII.GetString(hoursData)),
int.Parse(Encoding.ASCII.GetString(minutesData)),
int.Parse(Encoding.ASCII.GetString(secondsData)));
}
}
No comments:
Post a Comment