The binary file contains 8 bytes of type TDateTime (Date and Time), how in C # to read and convert to type DateTime?
- And what kind of data storage format is there? - Vladimir Martyanov
- @ Vladimir Martiyanov do not know. - creamsun
- I correctly understand, what in the binary file TDateTime contains? And they need to be correctly considered in the application C #? - kami
- @kami likely yes .. - creamsun
- 2TDateTime in Delphi is a simple Double. - BlackWitcher
|
2 answers
Since Delphi uses the Double type to store the date / time, you can read the time value into a double variable. And then try to convert to System.DataTime in C #. For example, try this:
Double dbl = 65985.3333; //Значение прочитанной переменной из бинарника. DateTime dt = DateTime.FromOADate(dbl) - double time turned out to be 1.92571966779543E-319 dt turned out {12/30/1899 0:00:00} - creamsun
- Your method works, you just had to count in a certain way, change the bytes and bits in a certain order, and then reassemble, convert and double the array of bytes, and then in time! Thank you ! - creamsun
- It's my pleasure. Yes, and this method is not mine) It was just originally assumed that these 8 bytes from the binary will be read exactly as TDataTime Delphi, i.e. just Double, and then we transfer them to DataTime in C #. In any case, glad. what earned! - BlackWitcher
|
I don’t know when I had a similar problem, it was solved quite simply in the structure a variable was created public DateTime t_k; and it reads data from a binary file using Marshal
|