I have a number of files that are named in TAI64N format here is a reference. When I try using this source it comes out negative with the assist of BitConverter.ToInt64
static void Main ( string[] args ) {
string[] filenames = new string[4]{
"4000000057b23bf30017a4bc",
"4000000057b23ef61dedacac",
"4000000057b24b1c2bab0614",
"4000000057b24ca521a230fc"
};
foreach (string filename in filenames) {
byte[] hexToBytes = StringToByteArray(filename);
long bytesToLong = BitConverter.ToInt64(hexToBytes, 0);
Console.WriteLine(bytesToLong); // Negative?
DateTime longToDateTime = new DateTime(bytesToLong);
}
}
public static byte[] StringToByteArray ( string hex ) {
return Enumerable.Range(0, hex.Length)
.Where(x => x % 2 == 0)
.Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
.ToArray();
}
What am I doing wrong?