Good day!
> I'm trying to get the Modified Time Stamp (that appears in Windows
> Explorer).
You should be able to use the System.IO.FileInfo.LastWriteTime (or
LastWriteTimeUtc) property to read the same date/time value that Windows
Explorer shows in its "Date Modified" column. The other date/time properties
published are CreationTime and LastAccessTime, equivalents of which can be
seen in Windows Explorer when you open properties of any file.
> But, in this case, if I've moved the file, it returns other date than
> Windows Explorer.
When moving or copying files, the LastWriteTime property should stay the
same, and I cannot think of a situation immediately where this wouldn't be
the case.
However, different file systems store dates and times with a different
precision. For example, the FAT and NTFS file systems are different, as
could be file systems on network file servers. Also note that if you are
accessing a file from a network drive, the last modified time of the file
usually comes from the server. So if the clocks on the server and your PC
are out of sync, then you could see different times.
But then again, FileInfo.LastWriteTime should always be the same as what
Windows Explorer reports.

Signature
Regards,
Mr. Jani Järvinen
C# MVP
Helsinki, Finland
janij@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Morten Wennevik - 10 Jul 2005 09:38 GMT
I can confirm this problem, tried moving and/or renaming the files and lastwritetime in my case got reset to DateTime 0 (1.1.1601) This is not the real lastwritetime as Ueslei said, Windows Explorer displays the correct time.
> Good day!
>
[quoted text clipped - 23 lines]
> But then again, FileInfo.LastWriteTime should always be the same as what
> Windows Explorer reports.

Signature
Happy coding!
Morten Wennevik [C# MVP]
Jani Järvinen [MVP] - 10 Jul 2005 12:15 GMT
Hi Morten!
> I can confirm this problem, tried moving and/or renaming
> the files and lastwritetime in my case got reset to DateTime 0.
I see -- haven't run into this problem myself. Instead, in those apps I've
been using it, LastWriteTime has been reliable, even if the files have been
moved and/or copied.
Could this be a bug in the framework version 1.1? Or a security issue of
somekind, where .NET cannot read the datatime info? I have yet to convert my
apps to .NET 2.0, so I'm not sure how the code works there.
Any ideas? If you want, we can continue discussing this of in the private
newsgroups.

Signature
Regards,
Mr. Jani Järvinen
C# MVP
Helsinki, Finland
janij@removethis.dystopia.fi
http://www.saunalahti.fi/janij/
Morten Wennevik - 10 Jul 2005 14:24 GMT
Hi Jani,
The problem seems to be fixed in Framework 2.0.
Upon closer inspection it appears that the 1.1 version of FileInfo returns a 'null' date if the file is not found.
I created a simple
FileInfo fi = new FileInfo("a.dat");
MessageBox.Show(fi.LastWriteTime.ToShortDateString());
Result is the correct date.
Changed the filename in windows explorer to a1.dat and ran the exact same code. I forgot to change the code to create a FileInfo for a1.dat since it had been renamed, but the code ran successfully and returned January 1st 1601. The 2.0 version recognized that there was no a.dat and gave an exception.
> Hi Morten!
>
[quoted text clipped - 11 lines]
> Any ideas? If you want, we can continue discussing this of in the private
> newsgroups.

Signature
Happy coding!
Morten Wennevik [C# MVP]