asp classic - How do I update a files content using vbscript without updating it's modified date? -
a few large sites online incorrect doctypes (4.0 not 4.01). have written script update files content updates date modified file , want keep it's original date, possible in vbscript (with classic asp)?
here code replace file contents:
' folder root here fileroot = "d:\myroothere\" ' use persits upload because need impersonation setting below set upload = server.createobject("persits.upload") ' set impersonation authorise file over-writing (this correct , working) upload.logonuser "localhost","myusername","mypassword" set dir = upload.directory(fileroot & "*.asp", sortby_type) each item in dir set objfso = createobject("scripting.filesystemobject") set objfile = objfso.opentextfile(fileroot & item.filename, forreading) strtext = objfile.readall objfile.close if instr(strtext,"html 4.0 transitional") strnewtext = replace(strtext,"html 4.0 transitional","html 4.01 transitional") set objfile = objfso.opentextfile(fileroot & item.filename, forwriting) objfile.writeline strnewtext objfile.close end if next set upload = nothing
i took example here
set objshell = createobject("shell.application") set objfolder = objshell.namespace(filepath) set objfolderitem = objfolder.parsename(filename) objfolderitem.modifydate = "01/01/2013 8:00:00 am"
and tested ok on file inside folder everyone
having full control
Comments
Post a Comment