I need to know when a file that I'm downloading was created, or last written to. Just the date is all I need (such as 6/17/2011). Normally, the file's date can be sussed out by its name, such as "DonQuixoteWasRight.2011-06-17.log"
The problem is that the file can have all sorts of different naming formats, perhaps not even containing the date, such as "SanchoPanzaWasLeft.txt"
I thought maybe the FileInfo class would ride in to the rescue, but with this code:
FileInfo fInfo = new FileInfo(SelectedFileName);
//DateTime when = fInfo.CreationTime; //or CreationTimeUtc?
DateTime when = fInfo.LastWriteTime; //or LastWriteTimeUtc?
return when;
...It simply returns the time that I accessed the file (although I neither created it nor explicitly wrote to it). Neither CreationTime nor LastWriteTime return the true CreationTime or LastWriteTime of the file. Is there a way to find out?
There is no true way to figure this out, whether the file is on a server or even if it is on your local computer, because the last modified date and other metadata can be changed by users.