FoxPro Programming
Preserve Datemodified
Hi Rick,
I would like to download files from the web and preserve the datemodified from webserver. Do you have a solution for me?
loHttp = CREATEOBJECT("wwHttp")
loHttp.HttpGet(tcRemotePath, , , tcLocalPath)
Regards Toni
You can't directly do that because you're not dealing with a file system - you're retrieving a binary stream and writing it out to disk.
What you can do however is capture the Last-modified
response header and then 'touch' the file and change the file date after you save it.
Something like this:
DO wwdotnetbridge
DO wwhttp
LOCAL loHttp as wwHttp, loBridge as wwDotNetBridge
LOCAL lcFile, lcDate
lcFile = "c:\temp\wwipstuff.zip"
*** Download file
loHttp = CREATEOBJECT("wwHttp")
loHttp.Get("https://west-wind.com/files/wwipstuff.zip","c:\temp\wwipstuff.zip")
IF(loHttp.nError != 0)
? loHttp.cErrorMsg
ReTURN
ENDIF
*** Get the Modified date
lcDate = loHttp.Gethttpheader("Last-modified")
? lcDate && GMT Date
loBridge = GetwwDotnetBridge()
*** Convert GMT Date to DateTime
ldDate = loBridge.InvokeStaticMethod("System.DateTime","Parse", lcDate)
? ldDate && Real date
*** Set the file Date
loFile = loBridge.CreateInstance("System.IO.FileInfo", lcFile)
loFile.LastWriteTime = ldDate
+++ Rick ---
Hi Rick,
wow, that's realy cool. The wwDotNetBridge is realy powerfull.
Thanks for you sample.
Regards Toni