Click to See Complete Forum and Search --> : how to check file modification time?


Guest 123
October 6th, 2002, 07:39 AM
I want to watch a file which it will be modified by another application,if this file has been modified then i'll open the file and read it.
i coudln't find any existed code on the internet to solve this problem,so i tried by myself,but i couldn't find the function that can read the date/time stamp of the file.
if you have any idea about preprogrammed code or about the function that check the date/time of the file please answer me as soon as possible.
thank you in advance.
Yaser...

PaulWendt
October 6th, 2002, 10:46 AM
This isn't something that C++ covers by itself. So, you'll have to
use some operating system dependent method. Here's a link
which could be helpful to you if you're on Windows machines:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getfileinformationbyhandle.asp

If you're on a unix machine, sadly, I don't know the answer.

--Paul

cup
October 6th, 2002, 11:49 AM
You can use stat on the filename on startup and run stat on it at specified intervals. The information returned by stat will give you the modification date/time. If you are using Windows, stat is called _stat.