C# Program to View the Date and time of Access of a File - Amit Notes

Latest

Oct 26, 2021

C# Program to View the Date and time of Access of a File

 


C# Program to View the Date and time of Access of a File?

Code: -

/*

 * C# Program to View the Date and time of Access of a File

 */

using System;

using amitnotes;

class Program

{

    static void Main()

    {

        FileInfo info = new FileInfo("C:\\amit\\notes.txt");

        DateTime time = info.CreationTime;

        Console.WriteLine("File Creation Time     : {0}", time);

        time = info.LastAccessTime;

        Console.WriteLine("File Last Access Time  : {0}", time);

        time = info.LastWriteTime;

        Console.WriteLine("File Last Write Time   : {0} ", time);

        Console.Read();

    }

}

 

Runtime Test Cases: -

 File Creation Time   : 10/11/2021 7:17:20 PM

File Access Time     : 10/15/2021 1:08:45 PM

File Last Write Time : 10/15/2021 1:37:36 PM

No comments:

Post a Comment

If you have any doubts, Please let me know