Get Last Modified Date and Time of a File Using LabWindows™/CVI™

Updated May 3, 2018

Reported In

Software

  • LabWindows/CVI Base

Issue Details

I am building a project in LabWindows™/CVI™ and would like to programatically find the date and time that a file was last modified.

Solution

LabWindows/CVI has 2 functions with this functionality. GetFileTime() finds the hour, minute, and second of last modification, and GetFileDate() gets the month, day, and year of last modification.

GetFileTime has 4 parameters: char fileName[], int *hours, int *minutes, int *seconds

  • fileName is the pathname to the file you wish to observe
  • hours, minutes, and seconds are the variable where you want to write the hour, minute, and second of last modification.
GetFileDate has 4 parameters: char fileName[], int *month, int *day, int *year
  • fileName is the pathname to the file you wish to observe
  • month, day, and year are the variable where you want to write the month, calendar day, and year of last modification.

Additional Information

All returned values have a defined range, as specified below:
  • year returns a number between 1980 and 2099
  • month returns a number between 1 and 12 (with 1 representing January, 12 representing December)
  • day returns a number between 1 and 31
  • hours returns a number between 0 and 23 (with 0 representing 12AM)
  • minutes returns a number between 0 and 59
  • seconds returns a number between 0 and 59

WAS THIS ARTICLE HELPFUL?

Not Helpful