![]() |
VOOZH | about |
Given a file, now our task is to get the file time using the File class. So we use the GetCreationTime() method of the File class. This method is used to find the creation date and time of the given file or directory. This method will only take one parameter that is the path of the file and if this path parameter does not exist, then it will return 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time.
Syntax:
public static DateTime GetCreationTime (string Ipath)
Here Ipath represents the path of the file or directory.
Return Type: The return type of this method is DateTime. It is a structure set to the date and time that the specified file.
Exceptions: It can have the following exceptions;
Example:
In this example, we are going to create a file named "file.txt" in the C drive, and the path is shown in the image:
👁 ImageOutput:
File is created at: 10/22/2021 1:02:10 PM