Reputation: 9
i am trying to get the File Created date Everything is working fine but if i am moving the file from one folder to another folder that it is loosing its actual date and returning the current date. i know it works on the directory and file creation Date. But i need the actual created date. Thanks for the help in Advance.
DateTime fileCreatedDate = File.GetCreationTime(file);
Upvotes: 0
Views: 679
Reputation: 43
This example shows how to get file time informations, when any file was created, last modified or accessed. To get file datetime info you can use either static methods of File class or instance methods of FileInfo class. https://www.csharp-examples.net/file-creation-modification-time/
Upvotes: 0
Reputation: 246
If the file is overriding another file in the same folder, or it's name is exactly similar to another deleted file, so it'll take the other file creation date because of file system tunnelling
An easy workaround is to read the creation date of the file before move it, then after moving it, set the creation date that you got using:
File.SetCreationTime
Upvotes: 1