Q:

C# program to get file creation time

0

Here, we have to create a file and print the time, when it is created.

File.GetCreationTime()

This is a method of "File" class, which returns the file creation time.

Syntax:

DateTime GetCreationTime(path);

Parameter(s):

path - Filename with its location.

Return value:

It returns a DateTime object. This contains following information:

  1. Month
  2. Date
  3. Year
  4. Hour
  5. Minutes
  6. Seconds
  7. AM and PM
  8.  

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Program

using System;
using System.IO;

namespace ConsoleApplication1
{
	class Program
	{
		static void Main()
		{
			DateTime D1 =  File.GetCreationTime("XYZ.TXT");
			Console.WriteLine("File Creation Time : "+D1.ToString());
		}
	}
}

Output

File Creation Time : 10/27/2017 6:53:39 PM

Note: In above program, we need to remember, when we use "File" class, System.IO namespace must be included in the program.

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C# file handling (File class) solved programs/examples

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
C# program to write text to a file... >>