使用fso修改文件特定内容的函数
FunctionFsochange(文件名,目标,字符串)
Dimobjfso,objcountfile,filetempdata
setObjfso = server.createobject(“ scripting.filesystemobject”)
setObjcountfile = objfso.opentextfile(server.mappath(filename),1,true)
filetempdata = objcountfile.readall
objcountfile.close
filetempdata =替换(filetempdata,target,string)
setObjcountfile = objfso.createTextfile(server.mappath(filename),true)
objcountfile.writefiletempdata
objcountfile.close
setObjcountfile =没有
setObjfso =什么都没有
最终功能
使用fso读取文件内容的函数
functionfsofileread(文件名)
Dimobjfso,objcountfile,filetempdata
setObjfso = server.createobject(“ scripting.filesystemobject”)
setObjcountfile = objfso.opentextfile(server.mappath(filename),1,true)
fsofileread = objcountfile.readall
objcountfile.close
setObjcountfile =没有
setObjfso =什么都没有
最终功能
使用fso读取文件某一行的函数
functionfsolinedIt(文件名,linenum)
ifineNum <1 thenexitFunction
Dimfso,f,temparray,tempcnt
setfso = server.createobject(“ scripting.filesystemobject”)
ifnotfso.fileexists(server.mappath(fileName))然后exeDfunction
setf = fso.opentextfile(server.mappath(filename),1)
ifnotf.atendofstreamthen
tempcnt = f.Readall
f.close
setf =没有
temparray = split(tempcnt,chr(13)和chr(10))
ifineNum> ubound(temparray)+1
出口
别的
fsolinedit = temparray(linenum-1)
Endif
Endif
最终功能
使用fso写文件某一行的函数
functionfsolinewrite(文件名,linenum,linecontent)
ifineNum <1 thenexitFunction
Dimfso,f,temparray,tempcnt
setfso = server.createobject(“ scripting.filesystemobject”)
ifnotfso.fileexists(server.mappath(fileName))然后exeDfunction
setf = fso.opentextfile(server.mappath(filename),1)
ifnotf.atendofstreamthen
tempcnt = f.Readall
f.close
temparray = split(tempcnt,chr(13)和chr(10))
ifineNum> ubound(temparray)+1
出口
别的
temparray(Linenum-1)= linecontent