C# Program to Get File Time Using File Class Last Updated : 01 Nov, 2021 Comments Improve Suggest changes Like Article Like Report 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; UnauthorizedAccessException: This exception occurs when the caller does not have the required permission.ArgumentException: This exception occurs when the user is given an argument of invalid type like zero-length string, contains one or more invalid characters.ArgumentNullException: This exception occurs when the file path is null.PathTooLongException: This exception occurs when the specified filepath, file name, or both exceed the system-defined maximum length.NotSupportedException: This exception will occur when the file path is in an invalid format.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: C# // C# program to get file time // using File Class using System; using System.IO; class GFG{ static void Main() { // Declaring a time variable that will store // the creation time of the file // Using GetCreationTime() method of File class DateTime createdtime = File.GetCreationTime("C://users//file.txt"); // Display the creation time of the file Console.WriteLine("File is created at: {0}", createdtime); } } Output: File is created at: 10/22/2021 1:02:10 PM Comment More infoAdvertise with us Next Article C# Program to Get File Time Using File Class G gottumukkala_sivanagulu Follow Improve Article Tags : C# CSharp-File-Handling CSharp-programs Similar Reads C# Program to View the Access Date and Time of a File Given a file, our task is to view the date and time of access to a file. So to do this we use the following properties of the FileSystemInfo class: 1. CreationTime: This property is used to get the time in which the file is created. Syntax: file.CreationTime Where the file is the path of the file an 2 min read C# - FileInfo Class Methods In this article, we will explain the FileInfo class, its methods, properties, etc. The System.IO namespace is one of the most important namespaces we used while we are working with files in C#. FileInfo Class:It does not have static methods and it can only be used on instantiated objects. The class 3 min read How to Find Linux File Creation Time using Debugfs? Everything is treated as a file in Linux, and all the information about a file is stored in inodes, which includes the crucial metadata about a file such as creation time, last modification, etc. Every file in Linux is identified by its inode number. In this article, we will be using debugf command 2 min read C# Program to Check the Information of the File Given a file, now our task is to view the information of this file through C#. So to do this task we use FileInfo class. This class provides different types of properties and methods for creating, copying, deleting, opening, and moving files. It is also, used for creating FileStream objects. So here 1 min read File.GetCreationTime() Method in C# with Examples File.GetCreationTime(String) is an inbuilt File class method which is used to return the creation date and time of the specified file or directory. Syntax: public static DateTime GetCreationTime (string path); Parameter: This function accepts a parameter which is illustrated below: path: This is the 2 min read Like