Having Trouble with File TimeStamp Conversion

  • Thread starter Thread starter Joseph Geretz
  • Start date Start date
J

Joseph Geretz

I'm transferring a file from server to workstation, using Web Service
Extensions and DIME. Along with the file, which travels as a DIME
attachment, I'm also sending along metadata information about the file as it
exists on the server. The metadata also travels as a DIME attachment in XML
format.

As you can see, the metadata contains several file timestamps. What I'm
trying to do is set the local file timestamps for Created, Modified and
Accessed to the same values as the file on the server. (The sample below
shows only the node for file creation; similar nodes are included in the XML
for last modified and last accessed.)

<fileinfo host="YOSSI" filespec="C:\SpeedControl.exe" size="1405672"
attributes="32">
<created display="6/16/2005 12:23:34 PM"
display_utc="6/16/2005 4:23:34 PM"
filetime="127634126149556455"
filetime_utc="127634270149556455"
/>
</fileinfo>

(In the following code statements FI is a FileInfo class.)

The filetime_utc attribute value is serialized into the XML as
FI.CreationTimeUtc.ToFileTime().ToString().

At the other end of the wire, on the local workstation, I attempt to
reconstitute this value as a DateTime value:

FI.CreationTimeUtc = Convert.ToDateTime(SFI.Created.FileTimeUTC)

However, I receive the following error: Invalid cast from Int64 to DateTime.

Any idea what I am doing wrong, and how can I do this properly?

Thanks very much for your help!

- Joe Geretz -
 
OK, I got it. The function I need is:

FI.CreationTimeUtc = DateTime.FromFileTime(SFI.Created.FileTimeUTC);

It's working nicely. File is created on the workstation with the same
datetime stamps as the file on the server.

- Joe Geretz -
 
Back
Top