C# Directory GetCreationTimeUtc

Description

Directory GetCreationTimeUtc Gets the creation date and time, in Coordinated Universal Time (UTC) format, of a directory.

Syntax

Directory.GetCreationTimeUtc has the following syntax.


public static DateTime GetCreationTimeUtc(
  string path
)

Parameters

Directory.GetCreationTimeUtc has the following parameters.

  • path - The path of the directory.

Returns

Directory.GetCreationTimeUtc method returns A structure that is set to the creation date and time for the specified directory. This value is expressed in UTC time.

Example

The following example illustrates the differences in output when using Coordinated Universal Time (UTC) output.


/*www .j av  a  2 s  .com*/
using System;
using System.IO;

public class DirectoryUTCTime
{
  public static void Main()
  {
     string n = @"C:\test\newdir";
     DateTime dtime1 = new DateTime(2014, 1, 3);
     DateTime dtime2 = new DateTime(1999, 1, 1);
    
     Directory.SetCreationTime(n, dtime1);
     Directory.SetLastAccessTimeUtc(n, dtime1);
    
     Console.WriteLine("Creation Date: {0}", Directory.GetCreationTime(n));
     Console.WriteLine("UTC creation Date: {0}", Directory.GetCreationTimeUtc(n));
     Console.WriteLine("Last write time: {0}", Directory.GetLastWriteTime(n));
     Console.WriteLine("UTC last write time: {0}", Directory.GetLastWriteTimeUtc(n));
     Console.WriteLine("Last access time: {0}", Directory.GetLastAccessTime(n));
     Console.WriteLine("UTC last access time: {0}", Directory.GetLastAccessTimeUtc(n));
    
     Directory.SetLastWriteTimeUtc(n, dtime2);
     Console.WriteLine("Changed last write time: {0}", Directory.GetLastWriteTimeUtc(n));
  }
}




















Home »
  C# Tutorial »
    System.IO »




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