Given a file and a directory and we have to get and print their last access time using C# program.
File.GetLastAccessTime()
This is a method of "File class, and it returns the last access time of a file/directory specified with the path.
Syntax:
File.GetLastAccessTime(path);
Parameter(s):
- path - Location of file or directory.
Last access time contain following detail:
- Date
- Month
- Year
- Hour
- Minute
- Second
- AM/PM
-
Program
Output
Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.