Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

It sounds like you're trying to find out when the file was modified on the server.

Unless the server explicitly tells you somehow, there is no way to find that out.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top