C# Directory GetLastAccessTimeUtc
Description
Directory GetLastAccessTimeUtc
Returns the date and
time, in Coordinated Universal Time (UTC) format, that the specified file
or directory was last accessed.
Syntax
Directory.GetLastAccessTimeUtc
has the following syntax.
public static DateTime GetLastAccessTimeUtc(
string path
)
Parameters
Directory.GetLastAccessTimeUtc
has the following parameters.
path
- The file or directory for which to obtain access date and time information.
Returns
Directory.GetLastAccessTimeUtc
method returns A structure that is set to the date and time the specified file or directory
was last accessed. This value is expressed in UTC time.
Example
The following example illustrates the differences in output when using Coordinated Universal Time (UTC) output.
using System;//from w w w .j a va 2 s .c om
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));
}
}