Home > Net >  How to get file date Accessed?
How to get file date Accessed?

Time:01-22

I'm looking for this function from std::filesystem but can't figure it out.

How to access this information?

enter image description here

CodePudding user response:

Only write time (Modified in your screenshot) is accessible via standard libraries. You'd need to use platform-specific APIs to get access to the other information.

For example, assuming Windows (based on the screen shot), you'd use GetFileTime(); this function is able to retrieve the created, modified, and accessed times. You will need a handle to the file. The link above includes a link to a full example, but summarizing the example essentially you can do:

HANDLE hFile = /* get the file handle */
FILETIME ftCreate, ftAccess, ftWrite;

GetFileTime(hFile, &ftCreate, &ftAccess, &ftWrite);
  •  Tags:  
  • Related