C# File GetCreationTime

Description

File GetCreationTime Returns the creation date and time of the specified file or directory.

Syntax

File.GetCreationTime has the following syntax.


public static DateTime GetCreationTime(
  string path
)

Parameters

File.GetCreationTime has the following parameters.

  • path - The file or directory for which to obtain creation date and time information.

Returns

File.GetCreationTime method returns A DateTime structure set to the creation date and time for the specified file or directory. This value is expressed in local time.

Example

The following example demonstrates GetCreationTime.


//  w  w  w .j  a v a  2 s  .com
using System;
using System.IO;

class Program{
 static void Main(string[] args){
   DateTime fileCreatedDate = File.GetCreationTime(@"C:\Example\MyTest.txt");
   Console.WriteLine("file created: " + fileCreatedDate);
 }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System.IO »




BinaryReader
BinaryWriter
Directory
DirectoryInfo
DriveInfo
File
FileInfo
FileStream
MemoryStream
Path
StreamReader
StreamWriter
StringReader
StringWriter