使用 FSO 修改文件特定内容的函数
functionFSoChange (nome do arquivo, destino, string)
DIMOBJFSO, OBJCOUNTFILE, FILETEMPDATA
Setobjfso = server.createObject ("scripting.filesystemoBject")
SetObjCountFile = objfso.opentExtFile (Server.mappath (nome do arquivo), 1, true)
FileTempData = objCountFile.readall
objCountFile.Close
FileTempData = Substitua (FileTempData, Target, String)
SetObJCountFile = objfso.createTextFile (Server.mappath (nome do arquivo), true)
objCountFile.WriteFilETEMPData
objCountFile.Close
SetoBJCountFile = nada
Setobjfso = nada
Função final
使用 FSO 读取文件内容的函数
functionfsofileRead (nome do arquivo)
DIMOBJFSO, OBJCOUNTFILE, FILETEMPDATA
Setobjfso = server.createObject ("scripting.filesystemoBject")
SetObjCountFile = objfso.opentExtFile (Server.mappath (nome do arquivo), 1, true)
FsofileRead = objCountFile.readall
objCountFile.Close
SetoBJCountFile = nada
Setobjfso = nada
Função final
使用 FSO 读取文件某一行的函数
functionFSolinedit (nome do arquivo, linho)
iflinenum <1ThenexitFunction
Dimfso, F, Temparray, Tempcnt
setfso = server.createObject ("scripting.filesystemobject")
ifnotfso.fileExists (Server.mappath (nome do arquivo)) ThenExitFunction
setf = fso.opentExtFile (Server.mappath (nome do arquivo), 1)
ifnotf.atendofstreamthen
tempcnt = f.readall
F.Close
setf = nada
Temparray = Split (Tempcnt, Chr (13) e Chr (10))
iflinenum> ubound (temparray)+1hen
saída de saída
outro
Fsolinedit = temparray (linho-1)
endif
endif
Função final
使用 FSO 写文件某一行的函数
functionFSolineWrite (nome do arquivo, linho, linecontent)
iflinenum <1ThenexitFunction
Dimfso, F, Temparray, Tempcnt
setfso = server.createObject ("scripting.filesystemobject")
ifnotfso.fileExists (Server.mappath (nome do arquivo)) ThenExitFunction
setf = fso.opentExtFile (Server.mappath (nome do arquivo), 1)
ifnotf.atendofstreamthen
tempcnt = f.readall
F.Close
Temparray = Split (Tempcnt, Chr (13) e Chr (10))
iflinenum> ubound (temparray)+1hen
saída de saída
outro
Temparray (linho-1) = LineContent