C# File GetLastAccessTime

Description

File GetLastAccessTime Returns the date and time the specified file or directory was last accessed.

Syntax

File.GetLastAccessTime has the following syntax.


public static DateTime GetLastAccessTime(
  string path
)

Parameters

File.GetLastAccessTime has the following parameters.

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

Returns

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

Example

The following example demonstrates GetLastAccessTime.


//  www  .  j ava2 s.  c  om

using System;
using System.IO;

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

        DateTime dt = File.GetLastAccessTime(path);
        Console.WriteLine("The last access 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