I'm wondering how I can change file creation time within C#?
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.
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.
using System.IO; ... DateTime newCreate = new DateTime(year, month, day, hour, minutes, seconds); File. SetCreationTime("changemydate. txt", newCreate);
A file's modification time describes when the content of the file most recently changed.
You can use the following method from System.IO
namespace:
File.SetCreationTime(fileName, fileTime);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With