Which type of the operating system you use?
Please provide a lot more detail about this.
If you use the Win, then :
You can use following function of WinAPI
BOOL GetFileTime(
HANDLE hFile,
LPFILETIME lpCreationTime,
LPFILETIME lpLastAccessTime,
LPFILETIME lpLastWriteTime
);
BOOL FileTimeToSystemTime(
const FILETIME* lpFileTime,
LPSYSTEMTIME lpSystemTime
);
If you need a other way,
You can following way for Unix platforms:
#include
#include <unistd.h>
#include <time.h>
struct tm* clock; // create a time structure
struct stat attrib; // create a file attribute structure
stat("afile.txt", &attrib); // get the attributes of afile.txt
clock = gmtime(&(attrib.st_mtime));
where:
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for file system I/O */
blkcnt_t st_blocks; /* number of 512B blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};
Or see here:
http://www.freebsd.org/cgi/man.cgi?query=stat&apropos=0&sektion=2&manpath=FreeBSD+5.3-RELEASE+and+Ports&format=html[
^]
Regards,
Alex.