Converting CTime read from a C++ archive file

C

Claire

I need to interface to an MFC CArchive file created with Visual Studio 6.
I've found some online sample code to translate an archived string into C#
I now need to read in and translate a CTime object. This is written to the
file as 4 bytes. Can anyone tell me the structure please


(It's a shame that Microsoft don't publish information on CArchive formats
in support for conversion to the dotnet framework)
 
M

Magnus Krisell

The CTime object is probably written as a (32-bit) time_t value that is
the number of seconds since Jan 1, 1970.

Thus, assuming reader is a BinaryReader instance, try the following code:

int seconds = reader.ReadInt32();
DateTime date = new DateTime(1970, 1, 1);
TimeSpan span = new TimeSpan(0, 0, 0, seconds);
date += span;
 
A

Ajay Kalra

You could use MFC and MC++ to read the file. This allows to mix native
and managed code together.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top