Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change file creation time in C#?

Tags:

c#

.net

file-io

I'm wondering how I can change file creation time within C#?

like image 670
Contango Avatar asked Mar 06 '12 18:03

Contango


People also ask

How do you change file creation time?

You can modify the date created by copying a file. The file's created date becomes the modified date and the current date (when the file is copied) becomes the created date. You can copy a file on your PC to check.

Can you change the timestamp of a file?

Unfortunately, this isn't possible. You can view certain and change certain file attributes in File Explorer, but you can't change the last viewed, edited, or modified dates.

How can I change the modified date of a file in C#?

using System.IO; ... DateTime newCreate = new DateTime(year, month, day, hour, minutes, seconds); File. SetCreationTime("changemydate. txt", newCreate);

What is file modification time?

A file's modification time describes when the content of the file most recently changed.


1 Answers

You can use the following method from System.IO namespace:

File.SetCreationTime(fileName, fileTime); 
like image 84
Daniel Peñalba Avatar answered Oct 11 '22 08:10

Daniel Peñalba