C# program to get last access time of file or directory

Program

using System;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main()
        {
            DateTime dt1;
            DateTime dt2;

            dt1 = File.GetLastAccessTime("ABC.TXT");
            Console.WriteLine("Last Access Time of file(ABC.TXT) : " + dt1);

            dt2 = File.GetLastAccessTime("mydir");
            Console.WriteLine("Last Access Time of directory(mydir) : " + dt2);
        }
    }
}

output

Last Access Time of file(ABC.TXT) : 10/31/2017 9:38:13 PM
Last Access Time of directory(mydir) : 10/31/2017 9:08:23 PM

Leave a Comment

error: Alert: Content is protected!!