locked
How can I convert a bigint stored in the FileSyncProvider metadata store to a DateTime object? RRS feed

  • Question

  • In the SqlMetadataStore created by the FileSyncProvider there is a CreationTime column, which is stored as a bigint. When I use the following code to read this value and convert it to a DateTime object the year is incorrect by 1600 years, i.e. when it should be 2010, it is actually 0410:

     

    DateTime.FromBinary((long)row["CreationTime"])

     

    I can fix this by adding 1600 years, but I'd like to know why this offset is needed? Is there a better way to read it in?

     

    DateTime.FromBinary((long)row["CreationTime"]).AddYears(1600)

     

    Is there any documentation of the other columns in the metadata store?

    Friday, October 22, 2010 1:22 PM

All replies

  • Hi -

    There is no documentation on any of the columns in the metadata store because this is internal. It is unsupported for you to reach into the metadata store in this fashion and try to read the CreationTime.

    I have not looked into this enough to know why 1600 is the magic number but the CreationTime was not written into the database using DateTime.ToBinary ( so it cannot be a direct conversion). We wrote the value directly from the Win32 FILETIME structure specified here and you will need to conver this in an equivalent fasion.

    http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx

     

    Thanks

    Deepa


    Deepa ( Microsoft Sync Framework)
    Friday, October 22, 2010 8:04 PM
    Answerer
  • Thanks. I understand that it is internal metadata but when it comes to diagnosing and debugging problems then this is sometimes the only way of trying to understand what the Sync Framework is doing.
    Sunday, October 24, 2010 12:07 PM
  • I've noticed that a lot of the samples use DateTime.ToBinary() but I have started using DateTime.ToFileTime() because of your reply. Does this sound correct? If so, should the samples be updated?

     

    Tuesday, October 26, 2010 1:09 PM