C# program to set new file creation time

C# program to set new file creation time

Program

using System;
using System.IO;

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

			DateTime D2 = new DateTime(2017, 12, 25, 19, 45, 10);

			File.SetCreationTime("XYZ.TXT", D2);

			DateTime D3 = File.GetCreationTime("XYZ.TXT");
			Console.WriteLine("New File Creation Time : " + D3.ToString());
		}
	}
}

Output

Old File Creation Time : 10/27/2017 10:45:10 AM
New File Creation Time : 12/25/2017 7:45:10 PM

Recent Posts

error: Alert: Content is protected!!