asp.net.ph

DateTime.FromFileTime Method

System Namespace   DateTime Structure


Returns a DateTime equivalent to the specified operating system file timestamp.

[ VB ]
<Serializable>
Public Shared Function FromFileTime ( _
   ByVal fileTime As Long _
} As DateTime

[ C# ]
[ Serializable ]
public static DateTime FromFileTime (
   long fileTime
};

[ C++ ]
[ Serializable ]
public: static DateTime FromFileTime (
   __int64 fileTime
};

[ JScript ]
public Serializable
static function FromFileTime (
   fileTime : long
} : DateTime;

Parameters

fileTime
A Windows file time.

Return Value

A DateTime value representing the date and time of fileTime, adjusted to local time.

Exceptions


Exception Type Condition
ArgumentOutOfRangeException fileTime is not valid.

Remarks

fileTime is a 64-bit signed integer value representing a Windows file timestamp. The timestamp is the number of 100-nanosecond intervals that have elapsed since January 1, 1601 12:00 A.M. coordinated universal time ( UTC ).

Example

The below code snippet demonstrates using the FromFileTime method.

public System.TimeSpan FileAge ( long fileCreationTime ) {

   System.DateTime now = System.DateTime.Now;

   try {
      System.DateTime fCreationTime =
         System.DateTime.FromFileTime ( fileCreationTime );
      System.TimeSpan fileAge = now.Subtract ( fCreationTime );
      return fileAge; 
   }
   catch ( ArgumentOutOfRangeException ) {
      // fileCreationTime is not valid, so re-throw the exception.
      throw;
   }
}
  C# VB

See Also

DateTime Members   ToUniversalTime   GetUtcOffset Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph