C# File GetLastWriteTimeUtc

Description

File GetLastWriteTimeUtc Returns the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.

Syntax

File.GetLastWriteTimeUtc has the following syntax.


public static DateTime GetLastWriteTimeUtc(
  string path
)

Parameters

File.GetLastWriteTimeUtc has the following parameters.

  • path - The file or directory for which to obtain write date and time information.

Returns

File.GetLastWriteTimeUtc method returns A DateTime structure set to the date and time that the specified file or directory was last written to. This value is expressed in UTC time.

Example

The following example demonstrates GetLastWriteTimeUtc.


/*from  w w  w  .j ava 2 s  .co  m*/

using System;
using System.IO;

class Test 
{
    public static void Main() 
    {
      string path = @"c:\Temp\MyTest.txt";
      File.SetLastWriteTime(path, new DateTime(2014,4,3));

      DateTime dt = File.GetLastWriteTimeUtc(path);
      Console.WriteLine("The last write time for this file was {0}.", dt);
      
    }
}




















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter