SysUtilsFileGetSetDate (C++)

From Appmethod Code Examples
Jump to: navigation, search

Description

This example illustrates the FileGetDate and FileSetDate functions from the SysUtils unit. In the case of a file called "test.txt", first get the date and time from that file, and then change it.

Code

int _tmain(int argc, _TCHAR* argv[])
{
	THandle h;
	int fdate;

	/* Open a file. */
	h = FileOpen("test.txt", fmOpenRead);
	/* Get the date from the file. */
	fdate = FileGetDate(h);
	/* Close the file. */
	FileClose(h);

	/* Increment the old date by one hour, then apply the new date. */
	FileSetDate("test.txt",
	   DateTimeToFileDate(
		  IncHour(FileDateToDateTime(fdate), 1)));

	return 0;
}

Uses