Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Setting a file's date
Message
From
24/11/1999 13:15:22
 
 
To
24/11/1999 11:56:09
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00295082
Message ID:
00295139
Views:
21
>>There are the FDATE() and FTIME() to get a file's last modification date/time, but is there a way to set that date/time?
>
>I don't think that allowed :-) Try setting the computers date and time via the API (Checkout the new Faqs), the open it up lowlevel and replace the first character with, the first character. Does this make sense?

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 VFP numeric.

You can adjust the code to fit your needs.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform