I'm using the following to change the creation date of a text file:
using System.IO; ... DateTime newCreate = new DateTime(year, month, day, hour, minutes, seconds); File.SetCreationTime("changemydate.txt", newCreate);
However this doesn't do anything. There is no error message, yet it doesn't change the date of the file at all.
I tried this in a dropbox folder as well as in a random folder without success
The DateTime newCreate
object seems to be correct though.
It would be great if somebody could point me to an idea...
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.
You can manually change the Last Modified Date/Time for a file using a free software called Attribute Changer from http://www.petges.lu/. You will need to remember the modified date/time of your presentation file, modify the file and then use Attribute Changer to set the modified date/time to the previous one.
Actually, each file has three different times:
To modify these times you can use
File.SetCreationTime(path, time); File.SetLastWriteTime(path, time); File.SetLastAccessTime(path, time);
respectively.
It seems, that if you want to change file date as it shown in file manager (e.g. Explorer) you should try something like that:
String path = @"changemydate.txt"; DateTime time = new DateTime(year, month, day, hour, minutes, seconds); if (File.Exists(path)) File.SetLastWriteTime(path, time);
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