0

一些大型网站在线使用不正确的文档类型(4.0 而不是 4.01)。我已经编写了一个脚本来更新包含此内容的任何文件,但它更新了为文件修改的日期,我想将其保留为原始日期,这在 vbscript(使用经典 asp)中是否可行?

这是我的代码来简单地替换文件内容:

' My folder root is here
FileRoot = "D:\myRootHere\"
' Now I use Persits upload because I need the impersonation setting below it
Set Upload = Server.CreateObject("Persits.Upload")
' Set impersonation to authorise file over-writing (this is correct and working)
Upload.LogonUser "localhost","myUsername","myPassword"
Set Dir = Upload.Directory(FileRoot & "*.asp", SORTBY_TYPE)
For 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") then
        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
4

1 回答 1

0

我从这里拿了这个例子

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.NameSpace(FilePath)
Set objFolderItem = objFolder.ParseName(FileName)

objFolderItem.ModifyDate = "01/01/2013 8:00:00 AM"

并在文件夹内的文件上测试Everyone正常Full Control

于 2013-05-09T02:43:39.127 回答