0

In Windows, if you go to a file's properties it shows the last access time right under the time last modified. This changes when I copy it.

How do I view this in C?

Jeroen Vannevel
  • 41,258
  • 21
  • 92
  • 157
  • You asked [a question earlier](http://stackoverflow.com/questions/20810035/determining-if-file-has-been-copied-or-not-in-c) which, according to later comments, was really this question. You should really have edited the old question (or deleted it) rather than ask a new one. At least you are now getting sensible answers... – Floris Dec 28 '13 at 03:07
  • 1
    @Floris IMHO the earlier question seemed to have a sensible answer even if it was was from an evil twin brother. (or is that that good twin, Hmmm?) ;-) – chux - Reinstate Monica Dec 28 '13 at 03:29
  • @Floris Not really a fan of suggesting that new users delete questions; if they get into the habit of deleting every time there's a problem with their question, it'll just make things worse for them. Editing the original is definitely the right call. – Dennis Meng Dec 28 '13 at 04:49
  • @DennisMeng I agree - but I only noticed this question as duplicate after I had already replied to the old one, and after a sensible answer had been given to the rephrased (this) one. – Floris Dec 28 '13 at 12:54
  • @chux thanks for noticing. Definitely evil twins. I figured out what the "real" original question was and answered it; then noticed this "duplicate" was getting attention... – Floris Dec 28 '13 at 12:56

2 Answers2

2

You can use the GetFileTime() function to get it. This MSDN article has more details about file times.

xxbbcc
  • 15,756
  • 5
  • 42
  • 76
0

The portable way of getting the last modified timestamp is by using fstat or stat. If you want to go the Windows-only route (by directly calling a Windows API), see @xxbbcc's answer.

See How can I get a file's size in C++? for a short piece of sample code that uses stat/fstat - only change for your purpose is that you'll want to read the time_t st_mtime field.

Community
  • 1
  • 1
fvu
  • 31,143
  • 5
  • 57
  • 77