File.GetCreationTime() Method in C# with Examples Last Updated : 28 Apr, 2020 Comments Improve Suggest changes Like Article Like Report 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 specified file path whose creation date and time is going to be returned. Exceptions: UnauthorizedAccessException: The caller does not have the required permission. ArgumentException: The path is a zero-length string, contains only white space, or one or more invalid characters as defined by InvalidPathChars. ArgumentNullException: The path is null. PathTooLongException: The given path, file name, or both exceed the system-defined maximum length. NotSupportedException: The path is in an invalid format. Return Value: Returns the creation date and time of the specified file or directory. Below are the programs to illustrate the File.GetCreationTime(String) method. Program 1: Before running the below code, a file file.txt is created with some contents shown below: CSharp // C# program to illustrate the usage // of File.GetCreationTime(String) method // Using System and System.IO namespaces using System; using System.IO; class GFG { static void Main(string[] args) { // Calling the GetCreationTime() function DateTime fileCreatedDate = File.GetCreationTime(@"file.txt"); // Printing the creation date and time of the // specified file Console.WriteLine("File created on: " + fileCreatedDate); } } Executing: File created on: 4/19/2020 4:02:54 AM Program 2: Before running the below code, two files were created shown below: CSharp // C# program to illustrate the usage // of File.GetCreationTime(String) method // Using System and System.IO namespaces using System; using System.IO; class GFG { static void Main(string[] args) { // Calling the GetCreationTime() function DateTime fileCreatedDate1 = File.GetCreationTime(@"file.txt"); DateTime fileCreatedDate2 = File.GetCreationTime(@"gfg.txt"); // Printing the creation date and time of the // specified file Console.WriteLine("File created on: " + fileCreatedDate1); Console.WriteLine("File created on: " + fileCreatedDate2); } } Executing: File created on: 4/19/2020 4:02:54 AM File created on: 4/19/2020 4:07:02 AM Comment More infoAdvertise with us Next Article File.GetCreationTime() Method in C# with Examples K Kanchan_Ray Follow Improve Article Tags : C# CSharp-File-Handling Similar Reads File.GetCreationTimeUtc() Method in C# with Examples File.GetCreationTimeUtc(String) is an inbuilt File class method which is used to return the creation date and time, in coordinated universal time (UTC), of the specified file or directory. Syntax: public static DateTime GetCreationTimeUtc (string path); Parameter: This function accepts a parameter w 2 min read File.GetLastWriteTime() Method in C# with Examples File.GetLastWriteTime(String) is an inbuilt File class method which is used to return the date and time the specified file or directory was last written to.Syntax:Â Â public static DateTime GetLastWriteTime (string path); Parameter: This function accepts a parameter which is illustrated below:Â Â path 2 min read File.GetLastWriteTimeUtc() Method in C# with Examples File.GetLastWriteTimeUtc(String) is an inbuilt File class method which is used to return the date and time, in coordinated universal time (UTC), that the specified file or directory was last written to.Syntax:Â Â public static DateTime GetLastWriteTimeUtc (string path); Parameter: This function accep 2 min read File.GetLastAccessTime() Method in C# with Examples File.GetLastAccessTime(String) is an inbuilt File class method which is used to return the date and time the specified file or directory was last accessed.Syntax:Â Â public static DateTime GetLastAccessTime (string path); Parameter: This function accepts a parameter which is illustrated below:Â Â path 2 min read File.GetLastAccessTimeUtc() Method in C# with Examples File.GetLastAccessTimeUtc(String) is an inbuilt File class method which is used to return the date and time, in coordinated universal time (UTC), that the specified file or directory was last accessed.Syntax:Â Â public static DateTime GetLastAccessTimeUtc (string path); Parameter: This function accep 2 min read Like