Good day to all, please help me understand, there is a binary file from which I read the file values, and I need to convert from doube to DateTime, the binary itself is being formed in C ++ Builder, later it will be rewritten ...
using (BinaryReader reader = new BinaryReader(File.Open(path, FileMode.Open))) { // пока не достигнут конец файла // считываем каждое значение из файла while (reader.PeekChar() > -1) { double t_n = reader.ReadDouble(); double t_k = reader.ReadDouble(); var time = Convert.ToDateTime(t_n); } } I get the error:
An unhandled exception of type 'System.InvalidCastException' occurred in mscorlib.dll
Additional information: Invalid casting "Double" to "DateTime". Tried it like this:
var tn_n = DateTime.FromOADate(t_n); I get the error:
An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll
Additional information: Not a valid OleAut date.
help me please
doubleduring recording. - VladDTDateTime t_n; TDateTime t_k;TDateTime t_n; TDateTime t_k;and further in the code:StringGrid16->Cells[i+1][1]= FormatDateTime("d.mm.yy' / 'h:mm",(per[j].t_n));Unfortunately, this is the maximum that I can give you now, because I now have only a program on Buildere which is also engaged in reading. Just based on the above, I thought DateTime would do - EthernetsTDateTimeand outputs it to a table, but I wonder how it is written to the file. - VladDTDateTime. Apparently,DateTime.FromOADateshould be correct . And on what value the exception takes off? What is the value ofTDateTime? - VladD