Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Changing a file's timestamp
Message
De
02/12/1999 16:43:02
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00298172
Message ID:
00298186
Vues:
13
This message has been marked as the solution to the initial question of the thread.
Hi Byran,

>How can I change a file's timestamp programatically?

Here's a post from Erik Moore:
**************
You can do this with the FoxTools Touch function. Here is some code I put together recently to do exactly that.
FUNCTION SetTimeStamp
	LPARA tcFileName, ttNewTimeStamp
	LOCAL loRegistry
	SET PROC TO clsheap ADDI
	SET LIBRARY TO "foxtools.fll" ADDI
	oRegistry = CREATEOBJECT("Registry")
	lnTimeZoneOffsetMinutes = DWORDToNum(oRegistry.GetStringValue(oRegistry.hkey_Local_Machine, ;
			"SYSTEM\CurrentControlSet\Control\TimeZoneInformation", "ActiveTimeBias", ""))
	lnOffsetSeconds = lnTimeZoneOffsetMinutes * 60
	
	ttNewTimeStamp = ttNewTimeStamp + lnOffsetSeconds
	RELEASE oRegistry
	IF FILE(tcFileName)
		=FoxTouch(tcFileName, YEAR(ttNewTimeStamp), MONTH(ttNewTimeStamp), DAY(ttNewTimeStamp), ;
							HOUR(ttNewTimeStamp), MINUTE(ttNewTimeStamp), SEC(ttNewTimeStamp))
		RETURN .T.
	ELSE
		RETURN .F.
	ENDIF
ENDFUNC
This function uses my registry class to get the TimeZone offset from the registry, and Ed Rauh's CLSHeap to translate the DWORD offset value to a Visual FoxPro numeric.

You can adjust the code to fit your needs.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform